How to Fix Broken Terminal Copy-Paste Formatting — Free Tool
You copy a perfectly readable block of text from your terminal, paste it into Slack or Telegram, and it looks like a formatting disaster — extra spaces everywhere, broken line wraps, invisible characters, and weird indentation. Sound familiar? Here is why it happens and how to fix it instantly.
In This Guide
Why Terminal Copy-Paste Looks Broken
Modern CLI tools like Claude Code, GitHub Copilot CLI, and rich terminal prompts render their output with markdown-style formatting — bold text, bullet points, code blocks, headings, colored output, and indented sections. Your terminal app (Terminal.app, iTerm2, Warp, Windows Terminal) faithfully renders all of this on screen.
The problem is that when you select and copy this rendered text, the terminal copies the visual representation — including all the extra whitespace used for alignment, the line breaks inserted by terminal width wrapping, and sometimes even invisible Unicode characters used for formatting. The underlying text is fine, but what lands on your clipboard is the rendered version with all its formatting baggage.
This is a terminal app limitation, not a bug in the CLI tool itself. The terminal does not distinguish between "content whitespace" and "formatting whitespace" when copying to clipboard.
Common Formatting Artifacts
Here are the most frequent issues you will encounter when pasting terminal output:
Extra Spaces
Multiple consecutive spaces where there should be one, caused by terminal column alignment
Broken Line Wraps
Lines split mid-sentence because the terminal window was narrower than the text
ANSI Escape Codes
Raw color codes like [31m or [0m appearing as visible text instead of colors
Box-Drawing Characters
Characters like ─, │, ┌, ┘ from terminal UI borders showing up in pasted text
Markdown Artifacts
Literal **, ##, ```, and - characters from rendered markdown formatting
Invisible Characters
Zero-width spaces, non-breaking spaces, and other Unicode control characters
How to Fix It — Free Terminal Text Cleaner
The fastest solution is to paste your terminal output into a cleaning tool that strips out all the formatting artifacts and gives you clean, readable text. Our Terminal Text Cleaner does exactly this — paste your messy terminal text, and it instantly removes ANSI codes, box-drawing characters, excess whitespace, and optionally markdown formatting.
How to use it:
- 1. Copy the text from your terminal (Cmd+C / Ctrl+C)
- 2. Paste it into the Terminal Text Cleaner input box
- 3. Toggle the cleaning options you need (ANSI codes, whitespace, markdown, etc.)
- 4. Copy the cleaned output and paste it wherever you need
Everything runs in your browser — your text is never sent to a server. The tool processes everything locally using JavaScript regex patterns, so it works instantly even with large blocks of text.
Which CLI Tools Are Most Affected
Any CLI tool that renders rich output in the terminal can produce copy-paste artifacts. Here are the most common ones developers run into:
Claude Code / Claude CLI
Renders markdown with bold, bullets, code blocks, and headings. Produces heavy formatting artifacts when copied.
GitHub Copilot CLI
Inline suggestions and explanations include formatted text that copies with extra whitespace.
npm / yarn output
Dependency trees, audit reports, and error messages use box-drawing characters and ANSI colors.
Docker / kubectl
Table output with column alignment adds extra spaces that break when pasted.
git log / git diff
Colored diffs and formatted log output include ANSI escape sequences.
Manual Workarounds
If you prefer fixing things manually, here are some approaches that work:
Paste as plain text
Use Cmd+Shift+V (Mac) or Ctrl+Shift+V (Windows/Linux) to paste without formatting. This helps in some apps but does not fix extra spaces or ANSI codes.
Pipe to clipboard from the command line
Instead of selecting text visually, pipe output directly: command | pbcopy (Mac) or command | clip (Windows). This captures the raw text without terminal rendering.
Use sed or tr to clean
Strip ANSI codes with sed 's/\x1b\[[0-9;]*m//g' — but this only handles color codes, not whitespace or markdown artifacts.
Prevention Tips
While you cannot fully prevent terminal formatting artifacts, you can minimize them:
Widen your terminal window before running commands — fewer forced line wraps means cleaner copy-paste
Use --no-color or --plain flags when available to disable ANSI coloring at the source
Redirect output to a file first (command > output.txt), then copy from the file
Some terminal apps like iTerm2 have a "Copy without formatting" option in preferences
For Claude Code specifically, you can redirect output or use the API directly for clean text
Clean Your Terminal Text Now
Paste your messy terminal output and get clean text in one click.
Open Terminal Text Cleaner →Intellure Team
The Intellure team builds free, privacy-first online tools that work entirely in your browser. We write guides to help you get the most from our tools and the web, sharing practical tips and insights from our experience as developers and makers.
Try These Free Tools
Related Articles
5 Free Online Tools Every Developer Needs
Discover the essential free online tools that every developer should bookmark — from JSON formatting and regex testing to Base64 encoding and UUID generation.
How to Trim Audio Files Online Without Losing Quality
Learn how to trim, crop, and cut audio files in your browser with zero quality loss. Covers lossless cutting, batch trimming, format preservation, and privacy-first processing.
How to Scan QR Codes Online: Free Tool & Guide
Learn how to scan QR codes from images, screenshots, and photos using a free online tool. No app needed — just your browser.