Markdown Code Blocks to Confluence
Turn Markdown fenced code blocks into Confluence {code} macros with syntax highlighting, and know when to use {noformat} instead.
Direct answer
Markdown fenced code blocks become Confluence {code} macros: ```python turns into {code:language=python} ... {code}. The language after the fence maps to the macro's language parameter, which drives Confluence's syntax highlighting.
Open Markdown to Confluence converterWhen to use this
- Code snippets pasted into Confluence lost their formatting or highlighting.
- Runbooks, API docs, or troubleshooting guides written in Markdown carry shell, Python, or JSON blocks.
- You need Confluence's copy-button code macro instead of an indented plain-text blob.
Steps
- Tag every Markdown fence with a language (```bash, ```python, ```json) so highlighting survives.
- Convert the document — each fence becomes a {code:language=...} macro.
- Paste through Insert > Markup and confirm each block renders as a code macro, not a paragraph.
- Use {noformat} for output logs or config dumps where highlighting is noise.
- Preview long lines: the code macro scrolls horizontally instead of wrapping.
Example conversion
```python
def retry(fn, attempts=3):
for i in range(attempts):
try:
return fn()
except TimeoutError:
continue
```{code:language=python}
def retry(fn, attempts=3):
for i in range(attempts):
try:
return fn()
except TimeoutError:
continue
{code}Common mistakes
- Do not leave fences untagged — {code} without a language renders but loses syntax highlighting.
- Do not use inline backticks for multi-line code; they become {{monospace}} text, not a code block.
- Do not nest a code fence inside a blockquote and expect both to survive — convert them separately.
FAQ
- Which languages does the Confluence code macro highlight?
- Common ones include bash, python, java, javascript, sql, xml, yaml, and json. If a language is not supported, the macro still renders the block as monospaced code without coloring.
- What is the difference between {code} and {noformat}?
- {code} adds syntax highlighting and a language label; {noformat} renders raw preformatted text with no highlighting. Use {noformat} for logs, diffs, and terminal output.
- How does inline Markdown code convert?
- Inline backticks like `npm install` become Confluence {{npm install}} monospace text, which renders inline rather than as a block.
- Why does my pasted code block show literal ``` characters?
- Confluence does not understand Markdown fences. Until they are converted to {code} macros, the backticks are just text — run the document through the converter first.
Related Confluence guides
Markdown Runbook to Confluence
Convert a Markdown runbook into Confluence wiki markup with steps, warnings, code blocks, and rollback notes.
Confluence Technical Spec Template
Format a Markdown technical spec for Confluence with problem, decision, architecture, tradeoffs, and open questions.
Markdown Incident Review to Confluence
Convert a Markdown incident review into a Confluence page with timeline, impact, root cause, and follow-up actions.
Markdown Meeting Notes to Confluence
Turn Markdown meeting notes into a Confluence page with decisions, action items, blockers, and links.
Paste Markdown into Confluence
Why pasted Markdown shows up as plain text in Confluence, and the two reliable ways to get it rendering: converted wiki markup or the editor's markdown handling.
Markdown Table to Confluence
Convert Markdown pipe tables into Confluence wiki markup tables with proper header rows, and avoid the collapses that happen when you paste tables directly.
Markdown Checklists to Confluence
Convert Markdown task lists (- [ ] and - [x]) into Confluence-friendly checklists using (/) and (x) status icons, or the editor's action items.