AI tools are great at generating code examples, configuration files, and technical documentation. But pasting that code into a document without losing the formatting is surprisingly difficult.
What goes wrong
When you copy a code block from ChatGPT and paste it into Google Docs, Word, or an email:
- The backtick fences appear literally: You see
```characters instead of a code block - Indentation is lost or flattened: Nested code loses its visual hierarchy
- Monospace font is gone: Code appears in the document's default font (like Arial or Times New Roman)
- No background distinction: The code blends into the surrounding text with no visual separation
The result is code that's hard to read and impossible to copy accurately from the document.
Why indentation matters
In many programming languages, indentation is meaningful:
def process_data(items):
results = []
for item in items:
if item.is_valid():
results.append(item.transform())
return results
If this pastes with flattened indentation:
def process_data(items):
results = []
for item in items:
if item.is_valid():
results.append(item.transform())
return results
The code is now incorrect. In Python, indentation defines code blocks. Without it, this code would throw a syntax error.
How different apps handle code
Google Docs
No native code block support. Pasted code uses the document font. Indentation is sometimes preserved as spaces but with no background or monospace styling.
Word
Slightly better. Pasted code can maintain some formatting if the source was HTML. But markdown code fences (backticks) are displayed literally.
Email (Gmail, Outlook)
Similar to Google Docs. No code block concept. Code pastes as regular text.
OneNote
Best of the rich text editors. Can display monospace text with some indentation, but still no code block styling from a paste.
Slack
Slack actually handles code blocks well if you paste mrkdwn with triple backticks. But standard markdown paste doesn't trigger this.
The solution
Unmarkdown™ converts markdown code blocks to properly styled code for each destination:
- Monospace font: Consolas (Word, OneNote), Courier New (Email), or the destination's default monospace
- Background styling: Light gray background that visually separates code from body text
- Preserved indentation: All whitespace and indentation is maintained exactly
- No backtick fences: The
```markers are removed; the styling indicates it's code
Example result
After conversion and pasting into Google Docs or Word, the code block appears with:
- Gray background
- Monospace font
- Correct indentation
- Clear visual separation from surrounding text
Inline code too
Markdown also uses single backticks for inline code: `variable_name`. This is commonly used in AI responses for technical terms, file names, and commands.
After conversion, inline code appears in monospace with a subtle background, distinct from the surrounding body text.
Tips for working with AI-generated code
Ask for the language label
When asking AI for code, specify the language: "Write a Python function that..." This ensures the AI uses the correct markdown fence: ```python instead of just ```. The language label helps with syntax highlighting in tools that support it.
Copy the full response
Don't try to select just the code block. Copy the entire AI response, paste into Unmarkdown™, and the code blocks are automatically detected and styled. Non-code sections are formatted too.
Check indentation after pasting
Especially for Python, YAML, and other whitespace-sensitive formats, verify that indentation was preserved correctly. Unmarkdown™ preserves it, but some further editing in the destination app might inadvertently change it.
Destination-specific notes
- Google Docs: Code blocks get monospace font and background. No syntax highlighting.
- Word: Consolas monospace with gray background. Blocks are visually separate.
- Email: Courier New monospace with gray background. Works across Gmail, Outlook, iCloud Mail.
- OneNote: Consolas monospace with light gray background. Correct indentation.
- Slack: Native triple-backtick code blocks. Gray background and monospace.
- Plain Text: Code content preserved as-is. No styling (it's plain text).
