# expand macro in Confluence storage format

URL: https://goingstellar.ro/reference/confluence-storage-format/expand/

The expand macro hides rich text behind a clickable title. It has a single parameter, title. Of the macros in this group it converts most cleanly, because ADF has a native expand node.

## Storage format

```xml
<ac:structured-macro ac:name="expand"><ac:parameter ac:name="title">Details</ac:parameter><ac:rich-text-body><p>hidden</p></ac:rich-text-body></ac:structured-macro>
```

## In the editor

- Select the insert button or type / and choose Expand, then edit the title (default 'Click here to expand...'). Per the Atlassian documentation.

## As ADF (Confluence Cloud)

The ADF that Confluence Cloud builds for:

```xml
<ac:structured-macro ac:name="expand"><ac:parameter ac:name="title">Details</ac:parameter><ac:rich-text-body><p>hidden</p></ac:rich-text-body></ac:structured-macro>
```

```json
{
 "type": "doc",
 "content": [
  {
   "type": "expand",
   "attrs": {
    "title": "Details"
   },
   "content": [
    {
     "type": "paragraph",
     "content": [
      {
       "text": "hidden",
       "type": "text"
      }
     ]
    }
   ]
  }
 ],
 "version": 1
}
```

## Examples

Storage format sent:

```xml
<ac:structured-macro ac:name="expand"><ac:parameter ac:name="title">Details</ac:parameter><ac:rich-text-body><p>hidden</p></ac:rich-text-body></ac:structured-macro>
```

Hide supporting detail behind a short title. The content starts collapsed.

Rendered view (HTML):

```html
<div class="expand-container conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="expand" id="expander-534763457"><div id="expander-control-534763457" class="expand-control"><span class="expand-control-icon icon"> </span><span class="expand-control-text">Details</span></div><div id="expander-content-534763457" class="expand-content expand-hidden"><p>hidden</p></div></div>
```

Storage format after the round trip through ADF:

```xml
<ac:structured-macro ac:name="expand" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="title">Details</ac:parameter><ac:rich-text-body><p>hidden</p></ac:rich-text-body></ac:structured-macro>
```

Sent to Confluence Cloud on 29 Nov 2026.

Storage format sent:

```xml
<ac:structured-macro ac:name="expand"><ac:rich-text-body><p>no title</p></ac:rich-text-body></ac:structured-macro>
```

Leave the title out. The label falls back to the default text.

Rendered view (HTML):

```html
<div class="expand-container conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="expand" id="expander-168454650"><div id="expander-control-168454650" class="expand-control"><span class="expand-control-icon icon"> </span><span class="expand-control-text">Click here to expand...</span></div><div id="expander-content-168454650" class="expand-content expand-hidden"><p>no title</p></div></div>
```

Storage format after the round trip through ADF:

```xml
<ac:structured-macro ac:name="expand" ac:schema-version="1" ac:macro-id="<id>"><ac:rich-text-body><p>no title</p></ac:rich-text-body></ac:structured-macro>
```

Sent to Confluence Cloud on 29 Nov 2026.

Storage format sent:

```xml
ADF:{"content": [{"attrs": {"title": "Details"}, "content": [{"content": [{"text": "hidden", "type": "text"}], "type": "paragraph"}], "type": "expand"}], "type": "doc", "version": 1}
```

Save an ADF expand node to storage. The result is the same macro as the hand-written one.

Rendered view (HTML):

```html
<div class="expand-container conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="expand" id="expander-960802996"><div id="expander-control-960802996" class="expand-control"><span class="expand-control-icon icon"> </span><span class="expand-control-text">Details</span></div><div id="expander-content-960802996" class="expand-content expand-hidden"><p>hidden</p></div></div>
```

Storage format after the round trip through ADF:

```xml
<ac:structured-macro ac:name="expand" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="title">Details</ac:parameter><ac:rich-text-body><p>hidden</p></ac:rich-text-body></ac:structured-macro>
```

Sent to Confluence Cloud on 29 Nov 2026.

Storage format sent:

```xml
<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">python</ac:parameter><ac:parameter ac:name="title">setup.py</ac:parameter><ac:parameter ac:name="linenumbers">true</ac:parameter><ac:parameter ac:name="collapse">true</ac:parameter><ac:parameter ac:name="theme">Midnight</ac:parameter><ac:parameter ac:name="firstline">10</ac:parameter><ac:plain-text-body><![CDATA[print("hi")]]></ac:plain-text-body></ac:structured-macro>
```

See what a code macro with a title and collapse becomes. Confluence wraps it in an expand macro.

Rendered view (HTML):

```html
<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;">
 <div class="codeHeader panelHeader pdl hide-border-bottom" style="border-bottom-width: 1px;">
  <b class="code-title">setup.py</b><span class="collapse-source expand-control" style="display:none;"><span class="expand-control-icon icon"> </span><span class="expand-control-text">Expand source</span></span><span class="collapse-spinner-wrapper"> </span>
 </div>
 <div class="codeContent panelContent pdl hide-toolbar">
  <pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: python; gutter: true; first-line: 10; theme: Midnight; collapse: true" data-theme="Midnight">print(&quot;hi&quot;)</pre>
 </div>
</div>
```

Storage format after the round trip through ADF:

```xml
<ac:structured-macro ac:name="expand" ac:schema-version="1" ac:local-id="<id>" ac:macro-id="<id>"><ac:parameter ac:name="title">setup.py</ac:parameter><ac:rich-text-body><ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">py</ac:parameter><ac:plain-text-body><![CDATA[print("hi")]]></ac:plain-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>
```

Sent to Confluence Cloud on 29 Nov 2026.

## What changes in conversion

- The title and the body survive unchanged in both directions, apart from the generated macro id.
- An expand without a title comes back without a title parameter. ADF holds an empty string and the default label is applied on display.
- A code macro with a title and collapse set is the one place an expand appears that was not written. Its title becomes the expand title.
- The tested expand started collapsed on the stored page.

## Pitfalls

- The label of an untitled expand is added when the page is shown. It is not in the storage text, so searching storage for it finds nothing.
- Put the hidden content in ac:rich-text-body, as in every tested expand.
- The documentation notes the content is shown expanded in PDF and HTML exports.

## Questions and answers

### What is the default title?

A stock label that begins with the word Click and ends with to expand, added in the stored view when no title is given.

### Does expand lose anything in ADF?

No parameter was lost in the tested runs. Only the macro id is regenerated.

## Related

- [code macro](https://goingstellar.ro/reference/confluence-storage-format/code-macro/)
- [info, note, tip and warning macros](https://goingstellar.ro/reference/confluence-storage-format/info-note-tip-warning/)
- [panel macro](https://goingstellar.ro/reference/confluence-storage-format/panel-macro/)
- [excerpt, excerpt-include and include macros](https://goingstellar.ro/reference/confluence-storage-format/excerpt-include/)

## Sources

- [Insert the expand macro (Atlassian Support)](https://support.atlassian.com/confluence-cloud/docs/insert-the-expand-macro/)
- [Atlassian Document Format: document structure (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/)

