Beautify Code for Word Docs and Presentations — Format Before You Paste
Table of Contents
If you've ever pasted code into a Word document, PowerPoint, or Google Slides, you know the result: collapsed indentation, wrong font, no syntax highlighting, and generally unreadable text. The formatting step you're missing is cleaning up the code before you paste it.
This guide explains how to use the free online code formatter to prepare code for documents and presentations, and how to handle syntax highlighting once you're in the document.
Why Format Code Before Pasting Into Docs
When you paste code into a document, the result depends on two things: the code's own formatting (indentation, line breaks) and the document's font/rendering. You can't control how the document renders the font, but you can control the code's structure before it goes in.
Reasons to format first:
- Consistent indentation — when the font changes to monospace (Courier or Consolas), messy indentation becomes very obvious
- Proper line lengths — very long lines in code wrap awkwardly in documents. Setting print width to 60-70 before formatting helps fit code into narrower column widths.
- Readable structure — nested code is nearly impossible to read without consistent indentation
- Professional appearance — if you're sharing documentation with clients or colleagues, well-formatted code signals care and competence
Tips for Formatting Code Specifically for Documents
Standard code formatting uses 80-character print width. Documents are narrower. Adjust accordingly:
- Print Width — set to 60-70 for Word/PowerPoint. This forces earlier line breaks that fit better in a document column.
- Tab Width — 2 spaces. In a document font, 4 spaces per indent level quickly makes deeply nested code wide and hard to read.
- Trailing commas — up to you. None or ES5 is cleaner for code snippets that aren't going into a version-controlled codebase.
After formatting, paste into a monospace-font code block in your document. In Word, use "Consolas" or "Courier New." In Google Docs, use "Courier New" or insert a code block via the Format menu.
Sell Custom Apparel — We Handle Printing & Free ShippingCode Images for Presentations — Formatting + Screenshots
For presentations (PowerPoint, Google Slides, Keynote), pasting text code often looks poor compared to an image. The better workflow:
- Format your code using the online formatter with a narrower print width (50-60 chars)
- Copy the formatted code
- Use the free code screenshot tool to generate a beautiful image with syntax highlighting, a macOS window frame, and a dark theme
- Insert the image into your slide
The result looks professional and prints clearly. Code screenshot tools like Carbon.sh do the same thing — our version is free with no watermark and no account required. See how to create beautiful code screenshots free.
Adding Syntax Highlighting in Word and Google Docs
Neither Word nor Google Docs has built-in syntax highlighting for code. Options:
- Word — use the "Macro to Color Code" approach or a third-party add-in. For simple code blocks, manually apply a fixed-width font and optionally bold keywords.
- Google Docs — use the Code Blocks add-on (Extensions menu) to apply Prism or Highlight.js syntax coloring
- Notion — has built-in code blocks with syntax highlighting. Type /code to insert one.
- Markdown-based docs — use triple backtick blocks with language identifier (plain text notation: "triple backticks js") for automatic highlighting in GitHub README, Notion, or any Markdown renderer
For any of these, start with well-formatted code from the formatter — highlighting messy code only makes the messiness more visible.
Format Your Code Before Pasting — Free
Clean up code for Word, PowerPoint, Google Docs, or any documentation. Instant, no signup.
Open Free Code FormatterFrequently Asked Questions
What font should I use for code in Word?
Consolas is the best monospace font for Word documents — it's installed by default on Windows and renders cleanly at small sizes. Courier New is the universal fallback. On Mac, Menlo is an alternative.
What print width should I use for A4 pages?
For A4 or Letter pages with standard margins and 10-12pt font, 60-70 character print width works well for most code. Shorter than standard code (80) to prevent line wrapping in the document.
Can I paste formatted code directly into a Confluence page?
Yes. Confluence has code macro blocks that accept plain text. Paste formatted code into a code block, set the language, and Confluence applies syntax highlighting automatically.

