Why Claude Code output pastes messy — and how to fix it
You ask Claude Code for a snippet, copy what looks like clean code, paste into your editor, and everything is broken. Here's what's actually happening — and the one-click fix.
The terminal is a renderer, not a clipboard
Claude Code runs in a terminal. Terminals draw text using a mix of characters, ANSI escape codes, and Unicode glyphs to produce the polished UI you see — line numbers, color highlighting, frames, and tool-call markers. None of those visual aids exist in the underlying text; they're drawn around it.
But when you select-and-copy from a terminal, your clipboard captures the rendered text — meaning the line numbers and frame characters come along as actual characters. Pasting that into VS Code or your IDE is when the mess shows up.
What gets copied that you don't want
- Line-number prefixes like
1\t,42│from the Read tool'scat -nformat. - ANSI escape codes like
\x1B[33mfor syntax highlighting that your editor renders as garbage. - Box-drawing characters like
─ │ ┌ ┐ └ ┘from tool-call frames. - Bullet markers like
●,⏺that prefix tool calls and assistant turns. - Indentation padding from the UI that becomes a multi-space leading indent on every line.
- Soft-wrap line breaks the terminal added at your window width, which split sentences that were originally one line.
The dumb fix and the smart fix
The dumb fix: select carefully, manually delete line numbers, run a regex find-replace, hand-fix indentation. Loses you 30 seconds and your patience every time.
The smart fix: paste into the cleaner on the homepage and copy the output. Each transform is a separate toggle so you stay in control: keep diff markers when you want them, drop indentation when it's padding rather than structure.
What the cleaner does, in order
- Normalises line endings to LF.
- Strips ANSI escape sequences.
- Removes Unicode box-drawing and arrow glyphs.
- Drops line-number prefixes (tab- and pipe-delimited).
- Strips tool-call bullet markers.
- Optionally removes diff +/- markers.
- Trims trailing whitespace per line.
- Detects and removes the common leading indent.
- Optionally rejoins soft-wrapped paragraphs.
- Collapses runs of blank lines.
Why client-side matters
Code snippets often contain tokens, internal hostnames, or proprietary logic. Sending them to a third-party server to clean whitespace is overkill at best and a security policy violation at worst. Every transform here runs in your browser via plain JavaScript — open DevTools and verify there are no network calls.
Ready to clean some output?
Go to the cleaner →