Unlocked once you research and build it at Operations level 20, the Scrapyard lets you permanently dismantle a ship you don't need in exchange for resources, blueprints for that same ship type, Ship XP, or ship parts -- and occasionally a shot at materials for the next tier up. Scrapping is irreversible, so double-check you're not about to feed your only usable hull into the furnace before you confirm.
What comes back depends on the ship's type and level and on your own Scrapyard's level -- upgrading the building, and asking your Alliance for a speed-up, both raise the payout and the dismantling speed. A ship also has to actually be scrappable: some hulls are excluded by design, some need a higher Scrapyard level than you currently have, and a ship that's assigned to a Drydock or out in space has to come home first.
Since Update 90, scrapping a maxed Grade 5 ship returns about 20% of the original G5 investment, plus about 2.5% toward a Grade 6 ship of matching rarity (the source's example is a G6 player). G5 scrapping runs on longer timers than G4. Final rewards are based on your Cost Efficiencies and the ship's percentage cost, so they track your progression. The Demolish button instantly removes a ship from your hangar. It gives no rewards and does not use the scrapping queue. Use it to free space fast. Some ships cannot be demolished, including the Realta, the Vengeance and all Grade 7 ships.