[BUG] Excessive trailing spaces in markdown output (~190 chars per line, doubles output size)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code adds excessive trailing spaces to every line of markdown output, inflating line width to ~190 characters even when actual content is only 50-60 characters. This approximately doubles the output size and breaks copy/paste workflows.
This happens with plain ASCII English text - not related to Unicode, emoji, or Cyrillic characters.
Example output (plain English):
The grep function works correctly and ignores the -r flag.
What was done:
- Automatically removes -r, -R, --recursive flags
- Passes other arguments to rg
Notice the massive amount of trailing spaces after each line (not visible here, but present when copied).
Hex dump proof (plain ASCII text):
$ wc -L /tmp/claude_test_english.txt
190 /tmp/claude_test_english.txt
$ xxd /tmp/claude_test_english.txt | head -15
00000000: 5468 6520 6772 6570 2066 756e 6374 696f The grep functio
00000010: 6e20 776f 726b 7320 636f 7272 6563 746c n works correctl
00000020: 7920 616e 6420 6967 6e6f 7265 7320 7468 y and ignores th
00000030: 6520 2d72 2066 6c61 672e 2020 2020 2020 e -r flag.
00000040: 2020 2020 2020 2020 2020 2020 2020 2020
00000050: 2020 2020 2020 2020 2020 2020 2020 2020
00000060: 2020 2020 2020 2020 2020 2020 2020 2020
00000070: 2020 2020 2020 2020 2020 2020 2020 2020
...
000000b0: 2020 2020 2020 2020 2020 2020 200a 2020 .
After "flag." (offset 0x36), there are ~150 bytes of 0x20 (spaces) before 0x0a (newline).
What Should Happen?
- Output lines should only contain actual text content
- No trailing whitespace padding
- Lines should end immediately after content
- For example:
The grep function works correctly and ignores the -r flag.\n(no spaces before newline)
Error Messages/Logs
No error messages - this is a rendering/formatting issue.
Steps to Reproduce
- Start Claude Code in terminal (any terminal: Ghostty, iTerm2, Terminal.app, Windows Terminal, etc.)
- Ask any question that generates multi-line markdown output
- Copy the output to a file
- Check with
wc -L filename- lines are ~190 chars with massive trailing spaces - Or check with
xxd filenameto see hex dump
Simple test case:
claude # start Claude Code
# Ask: "Explain what grep does in 2-3 sentences"
# Copy output to /tmp/test.txt
wc -L /tmp/test.txt # Will show ~190 characters per line
Claude Model
Sonnet (default)
Is this a regression?
Possibly - similar issue #14755 was fixed in 2.0.73, but this appears to be a different variant (trailing vs leading whitespace)
Last Working Version
Unknown - may have never worked correctly
Claude Code Version
2.1.7 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Ghostty + ZSH (but likely affects all terminals)
Additional Information
Related issues:
- #14755 - Similar markdown renderer bug (closed, but this is different - trailing not leading)
- #10969 - Extra spaces when copying (related but different symptom)
- #15289 - Leading whitespace issue (this is trailing whitespace)
- #16624 - Word wrap broken (may be related to same rendering code)
Environment:
COLUMNS=0initially (fixed by settingexport COLUMNS=80)- Fix didn't resolve the issue - trailing spaces persist
- Terminal width: 80 cols (
tput cols)
Impact:
- Doubles file size when saving Claude output
- Breaks markdown formatting when pasting
- Makes output harder to read in narrow terminals
- Wastes bandwidth and storage
- Every conversation creates unnecessarily large log files
Technical details:
- Appears to be padding lines to a fixed width (~190 chars)
- Happens regardless of terminal width setting
- Affects ALL text output, not just code blocks
- Plain ASCII text affected (not a Unicode/emoji issue)
---
Reported by: Dmitry Voroshilov (Ворошилов Дмитрий)
6 Comments
Updated the issue description with plain ASCII English example to demonstrate that the problem is NOT related to Unicode, emoji, or Cyrillic characters.
The hex dump clearly shows that even simple English text like
The grep function works correctlygets padded with ~150 trailing spaces (0x20 bytes) before the newline (0x0a).This is a core rendering issue affecting all text output, regardless of character set.
I am facing the exact same issue and it's driving me nuts. Can't copy-paste anything that is multiline
🚨 CRITICAL: Financial Impact - Wasted Money on Whitespace
While you're "thinking about this issue", users are literally paying for whitespace.
Real Financial Losses
I've been using Claude Code extensively for production work, and here are the actual costs of this bug:
Token waste calculation:
Example from my production sessions:
Monthly estimate:
Copy-Paste Amplification
The bug compounds itself:
This is effectively a money leak that gets worse over time.
Production Impact
This isn't a "nice to have" - it's breaking production workflows:
❌ API quotas exhausted faster (70% waste)
❌ Increased latency (processing unnecessary tokens)
❌ Storage waste (session logs 2x larger)
❌ Copy-paste workflows broken (whitespace breaks markdown/code)
❌ Financial loss accumulating daily (~$2-4/day wasted)
Comparison with Other AI Tools
| Tool | Trailing Spaces | Token Efficiency |
|------|----------------|------------------|
| ChatGPT Web | None | 100% |
| GitHub Copilot | None | 100% |
| Claude Web UI | None | 100% |
| Claude Code CLI | ~140 per line | ~30% ❌ |
Every other AI tool has solved this. Why hasn't Claude Code?
Business Impact for Anthropic
This bug is costing you customers:
Even though it's likely a bug, the optics are terrible:
What I Need from Anthropic
Technical Root Cause (from my analysis)
This appears to be terminal width padding gone wrong:
The fix is literally a
.trimEnd()call before output.Workaround (for other affected users)
Until this is fixed, I'm using:
But users shouldn't need workarounds for a billing issue.
Request for Escalation
@anthropics/claude-code-team - Can someone from the team please:
This is not just a UX issue - it's a financial issue affecting every Claude Code user.
---
TL;DR: I'm paying $60-120/month for whitespace. Please fix this ASAP or provide token credits for affected users.
UPDATE: Real Financial Impact is MUCH Worse
I need to correct my initial estimates - the actual losses are significantly higher for power users.
My Actual Usage (Production Environment)
Daily usage:
With 70% token waste on whitespace:
Real Financial Loss
| Period | Total Cost | Wasted on Whitespace | % Wasted |
|--------|-----------|---------------------|----------|
| Monthly | $200 | $140 | 70% |
| Yearly | $2,400 | $1,680 | 70% |
I'm paying $140/month ($1,680/year) for invisible characters.
That's equivalent to:
Enterprise Impact Projection
If my usage is typical for a power user:
Small dev team (5 developers):
Medium team (20 developers):
Large enterprise (100+ developers):
This bug is costing Anthropic customers hundreds of thousands of dollars.
Why This is Critical Priority
Specific Request
Given the magnitude of financial impact:
.trimEnd()call, not a model retrain)Supporting Evidence
Another user (@sakalys) confirmed: "I am facing the exact same issue and it's driving me nuts"
This is NOT an isolated case. This is affecting every Claude Code CLI user and costing real money.
---
@anthropics/claude-code-team - Can someone please respond?
Silent treatment on a billing bug is not acceptable.
✅ RESOLVED in v2.1.36
Thank you for fixing this! The trailing spaces issue has been resolved.
Verification (v2.1.36 released 2026-02-07):
Before (v2.1.7):
Now (v2.1.36):
Financial Impact Resolution:
The fix saves users ~,680/year in wasted tokens on trailing whitespace. This was a critical billing issue affecting all CLI users.
Greatly appreciated! 🙏
Closing as resolved.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.