[BUG] Excessive trailing spaces in markdown output (~190 chars per line, doubles output size)

Resolved 💬 6 comments Opened Jan 14, 2026 by DmitruNS Closed Feb 7, 2026

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

  1. Start Claude Code in terminal (any terminal: Ghostty, iTerm2, Terminal.app, Windows Terminal, etc.)
  2. Ask any question that generates multi-line markdown output
  3. Copy the output to a file
  4. Check with wc -L filename - lines are ~190 chars with massive trailing spaces
  5. Or check with xxd filename to 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=0 initially (fixed by setting export 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 (Ворошилов Дмитрий)

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗