The Hidden Cost of Readability: How Code Formatting Silently Consumes Your LLM Budget
On the map: Efficient LLM inference and serving → Efficient reasoning and agent inference
Abstract (arXiv)
Source code is usually formatted with elements like indentation and newlines to improve readability for human developers. However, these visual aids do not seem to be beneficial for large language models (LLMs) in the same way since the code is processed as a linear sequence of tokens. Furthermore, these additional tokens can lead to increased computational costs and longer response times for LLMs. If such formatting elements are non-essential to LLMs, we can reduce such costs by removing them from the code. To figure out the role played by formatting elements, we conduct a comprehensive empirical study to evaluate the impact of code formatting on LLM performance and efficiency. Through large-scale experiments on Fill-in-the-Middle Code Completion tasks across four programming languages (Java, Python, C++, C#) and ten LLMs-including both commercial and open-source models-we systematically analyze token count and performance when formatting elements are removed. Key findings indicate that LLMs can maintain performance across formatted code and unformatted code, achieving an average input token reduction of 24.5% with negligible output token reductions. This makes code format removal a practical optimization strategy for improving LLM efficiency. Further exploration reveals that both prompting and fine-tuning LLMs can lead to significant reductions (up to 36.1%) in output code length without compromising correctness. To facilitate practical applications, we develop a bidirectional code transformation tool for format processing, which can be seamlessly integrated into existing LLM inference workflows, ensuring both human readability and LLM efficiency.
Key facts. Cited by 12 papers in the map (data through 14 Oct 2026). Placed in Efficient reasoning and agent inference, one of 12 directions in Efficient LLM inference and serving. Builds on 18 of its 38 references that are in the map. First posted on arXiv 19 Aug 2025.
Builds on
18 of 38 references.
References · 18
- 2023QLoRA: Efficient Finetuning of Quantized LLMscited by 3,418
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,918
- 2024Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phonecited by 1,917
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2023Think before you speak: Training Language Models With Pause Tokenscited by 264
- 2023Magicoder: Empowering Code Generation with OSS-Instructcited by 256
- 2022Efficient Training of Language Models to Fill in the Middlecited by 255
- 2022Diet Code Is Healthy: Simplifying Programs for Pre-trained Models of Codecited by 24
- 2020Probing Model Signal-Awareness via Prediction-Preserving Input Minimizationcited by 14
- 2022Don't Complete It! Preventing Unhelpful Code Completion for Productive and Sustainable Neural Code Completion Systemscited by 13
6 more
- 2024When Neural Code Completion Models Size up the Situation: Attaining Cheaper and Faster Completion through Dynamic Model Inferencecited by 10
- 2024AI Coders Are Among Us: Rethinking Programming Language Grammar Towards Efficient Code Generationcited by 10
- 2024Comparing large language models and human programmers for generating programming codecited by 9
- 2022Syntax-Guided Program Reduction for Understanding Neural Code Intelligence Modelscited by 7
- 2019STYLE-ANALYZER: fixing code style inconsistencies with interpretable unsupervised algorithmscited by 6
- 2024Is Next Token Prediction Sufficient for GPT? Exploration on Code Logic Comprehensioncited by 6
Built on by
Citing papers per year: 2025: 2; 2026: 10.
12 papers.
- 2025Reducing Cost of LLM Agents with Trajectory Reductioncited by 48
- 2026Seeing is Coding: On the Effectiveness of Vision Language Models in Code Understandingcited by 13
- 2025EfficientUICoder: A Bidirectional Token Compression Framework for Efficient MLLM-Based UI Code Generationcited by 5
- 2026The Devil Is in the Interface: Evaluating How Tool Architecture Shapes Coding Agent Behaviorcited by 3
- 2026Characterizing Readability Issue Patterns and the Role of Prompt Design in LLM-Generated Codecited by 1
- 2026The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languagescited by 1
- 2026AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agentscited by 1
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reusecited by 0
- 2026CodeShrink: Adaptive Visual Compression for Efficient Multimodal Code Understandingcited by 0
- 2026Talking to Itself While Coding: What Makes Comments Help Code Generation?cited by 0
- 2026Analyzing and Mitigating Cost-Inefficient Behaviors in Coding Agentscited by 0
- 2026Mind the Gaps: From Failure Attribution to Closed-Form Repair of Code Language Modelscited by 0
- 2026Mind the Gaps: From Failure Attribution to Closed-Form Repair of Code Language Models4 Oct 2026
- 2026Analyzing and Mitigating Cost-Inefficient Behaviors in Coding Agents25 Sep 2026
- 2026Talking to Itself While Coding: What Makes Comments Help Code Generation?8 Sep 2026
- 2026AttnCompress: Dynamic Attention-Guided Trajectory Compression for Software Engineering Agents8 Sep 2026
- 2026The Devil Is in the Interface: Evaluating How Tool Architecture Shapes Coding Agent Behavior11 Aug 2026
- 2026CodeShrink: Adaptive Visual Compression for Efficient Multimodal Code Understanding31 Jul 2026
- 2026The Best Programming Language for Tokenmaxxing: An Investigation of Coding Agent Behavior Across Programming Languages24 Jul 2026
- 2026FlowArk: Boosting Agentic Data-flow Analysis for Android Apps via Context-Aware Knowledge Reuse13 Jul 2026
- 2026Characterizing Readability Issue Patterns and the Role of Prompt Design in LLM-Generated Code13 May 2026
- 2026Seeing is Coding: On the Effectiveness of Vision Language Models in Code Understanding2 Feb 2026
- 2025Reducing Cost of LLM Agents with Trajectory Reduction28 Sep 2025
- 2025EfficientUICoder: A Bidirectional Token Compression Framework for Efficient MLLM-Based UI Code Generation15 Sep 2025
Similar, not cited
Close in wording, no citation either way
- 2025code_transformed: The Influence of Large Language Models on Code
- 2025Measuring how changes in code readability attributes affect code quality evaluation by Large Language Models
- 2024Does Prompt Formatting Have Any Impact on LLM Performance?
- 2025A Study of LLMs' Preferences for Libraries and Programming Languages
- 2026Compressed code: the hidden effects of quantization and distillation on programming tokens
- 2026PromptResponse: Optimizing Prompts for LLM Coding Tasks
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation
- 2025Human-Aligned Code Readability Assessment with Large Language Models ↗