Skip to main content

How to Display & Format JSON in Confluence (Code Blocks + Viewer)

· 4 min read

Confluence's native code block macro renders JSON as plain text — no real syntax highlighting, no themes, no copy button. For API documentation, config references, or any page where JSON needs to be readable, that's not good enough. There are two better ways to embed JSON in Confluence, and the best one depends on how you want readers to interact with the data.

Two approaches
  1. Modern Code Blocks — renders JSON as syntax-highlighted code with the Monaco editor (VS Code engine), 50+ themes, line numbers, copy button, and dark/light mode. Best for API docs, snippets, and most use cases.
  2. JSON Structure Viewer — renders JSON as an interactive collapsible tree you can zoom and rotate. Best for exploring large, deeply nested structures.

Method 1: Modern Code Blocks (syntax-highlighted JSON)

Modern Code Blocks for Confluence uses the Monaco editor — the same engine behind VS Code — to render JSON with proper syntax highlighting, 50+ themes, line numbers, a copy button, and automatic dark/light theme matching. It supports 85+ languages total, with first-class JSON support including nested object and array coloring.

Step-by-step

  1. Install Modern Code Blocks from the Marketplace (free for up to 10 users)
  2. Edit a Confluence page, type /code and select Modern Code Blocks for Confluence
  3. Paste your JSON into the editor
  4. Set the Language to JSON
  5. Optionally pick a Theme (Monokai, Dracula, GitHub Dark, or Auto to match Confluence)
  6. Click Save

The JSON renders inline with full syntax highlighting. Example output:

{
"user": {
"id": 1234,
"name": "Jane Developer",
"email": "jane@example.com",
"roles": ["admin", "editor"],
"preferences": {
"theme": "dark",
"notifications": {
"email": true,
"slack": false
}
}
}
}

Why Code Blocks wins for most JSON use cases

  • Monaco-grade highlighting — keys, strings, numbers, booleans, and null each get distinct colors
  • 50+ themes — match your brand or your reader's preference (Auto follows Confluence dark/light mode)
  • Line numbers and copy button — readers can reference line 42 and copy the payload with one click
  • Window chrome — optional macOS/Windows title bar (auto-derived filename, e.g. config.json) for screenshot-ready snippets
  • Diff view (Advanced edition) — show a JSON migration or config change as a colored before/after
  • One app for all code — the same macro handles JSON, YAML, SQL, Python, and 80+ other languages

For full configuration options — themes, max height, font size, minimap, window chrome — see the Modern Code Blocks user guide.

Method 2: JSON Structure Viewer (interactive tree)

When JSON is large or deeply nested and readers need to explore the structure rather than read it line by line, JSON Structure Viewer for Confluence renders the data as an interactive, collapsible tree. Readers click nodes to expand and collapse, and can zoom and rotate the diagram.

When to pick the tree view over code highlighting

Use caseBest choice
API request/response examples in docsCode Blocks (copy button, line numbers)
Short JSON snippets in tutorialsCode Blocks (themes, syntax colors)
A 500-line config file readers must navigateJSON Structure Viewer (collapsible tree)
Showing the shape of a data modelJSON Structure Viewer (visual hierarchy)
Changelog / migration diffCode Blocks diff view
Mixed code (JSON + YAML + SQL) on one pageCode Blocks (one macro, 85+ languages)

To use the tree view, install JSON Structure Viewer, type /json on a page, and paste your JSON. See the JSON Structure Viewer docs for details.

Tips for documenting JSON in Confluence

  • Pair the two apps — use Code Blocks for the readable snippet and Structure Viewer for the explorable tree on the same API-docs page
  • Anonymize sensitive data — replace real credentials and emails with placeholders before embedding
  • Break up large files — one macro per major section reads better than one massive blob
  • Use Markdown alongsideEnhanced Markdown for Confluence lets you write prose in Markdown and embed JSON macros inline

Try JSON Structure Viewer for Confluence

Visualize JSON as interactive structure diagrams — free for up to 10 users.

Get it on the Atlassian Marketplace