Developer
News and Updates
Get Support
Sign in
Get Support
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Last updated Sep 1, 2026

ADF node: codeBlock

Node

Description

The codeBlock node is a container for lines of code.

This is roughly equivalent to the combination of the <pre> and <code> HTML tags, although there may be more complicated styling, including language-aware syntax highlighting.

If the language is unspecified or its value is not one of the supported languages, then the codeBlock renders as plain, monospace text.

Although codeBlock accepts text nodes as content, they are not permitted to use any marks.

Example

Java

1
2
3
codeBlock("var foo = {};\nvar bar = [];")
        .language("javascript");

ADF

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "type": "codeBlock",
  "attrs": {
    "language": "javascript"
  },
  "content": [
    {
      "type": "text",
      "text": "var foo = {};\nvar bar = [];"
    }
  ]
}

Result

1
2
3
    var foo = {};
    var bar = [];

Note: This example output is not using AtlasKit to render the code block, so while it gives a vague impression of what a “code block” is, it does not faithfully reproduce the actual presentation in Atlassian products. In particular, this is a different syntax highlighting color scheme.

Compatibility

Products

ConfluenceJira

Usage

Marks

Structure

  • type - codeBlock
  • content - array(text…) – no marks1
  • marks - array(breakout)
  • attrs? – optional2
    • language? - string
    • localId? - string3
    • uniqueId? - string4

  1. Although text nodes are usually permitted to have marks, such as strong and link, these are not permitted inside a codeBlock.↩︎
  2. The attrs property is optional in the JSON schema and need not be provided to successfully parse these nodes. However, the Fabric Editor always includes the attrs map even when the language is not specified.↩︎
  3. The localId, when present, will typically be a random UUID. This is not enforced by the schema.↩︎
  4. The uniqueId property has not been documented internally. It appears to be redundant, serving the same function that localId serves for other nodes and attributes, just without following that standard naming convention. Your humble documentation author speculates that it probably isn’t used.↩︎

Rate this page: