How to create an "Expand All" button for Confluence


I've been using the expand macro a lot to organise my data (like a faq) but and am now having trouble searching for things (using the quick search). I can use the quick search to locate the page I'm after. But then I need to manually toggle open each and every expand field, before I can use the normal cntrl-f to find what I'm looking for.

Does anyone know of a way I can install an addon with this Expand All feature, or possibly a way to code my own macro?

A massive thanks in advance for helping!


7 answers

1 accepted

Thanks Ernie, your comments and code is really helpful.
This should be all we need for now!

this links directs to the confluence documentation

yeah, I wish I were able to see the javascript solution that Timothy finds so helpful.  This documentation page is exactly the opposite of what I'm looking for: it shows how to implement the "expand" section that I find so annoying!

hello , i don't know if you find the solution but after looking in to a lot of pages i tried this and it work :

1- first create user macro:

general configuration -> user macro >create a user Macro

name your macro expandall then past this and save it :


## Macro title: Expand All
## Macro has a body: N
## Developed by: George Lewe
## Date created: 2014-09-22
## Installed by: George Lewe
## @noparams
<a id="toggleAll" href="#">Expand/Collapse All</a>
<script type="text/javascript">
AJS.toInit(function ()
jQuery(".expand-control").each(function(){ jQuery(this).trigger("click");})
2-if you want to put this macro on one page you can just do this 

but if you want to add this to all pages in the confluence :

go to look and feel -> layout -> page layout -> add it where you want  :

    #set($helper = $action.helper)

Thank you, 




That was exactly what we needed, worked like a charm ... you rock, Amna!

Hi, Is there another way to add this to all pages when you use the Documentation theme as I get a message "You can not customise the site look and feel while a theme is active. You must first disable the currently configured theme."? Thanks

This was great.  Worked perfectly.

No need for jQuery, you can do this in plain ES6 these days:

[]'.expand-control'), x =>
No user macro required. Stick this at the bottom of the page in an HTML macro and you're done.
<script type="text/javascript">
AJS.toInit(function() {

Works like a charm!

Step 1: Insert a html macro. 


Step 2 : Paste the following. 


<a id="toggleAll" href="#">Expand/Collapse All sections</a>
<script type="text/javascript">
AJS.toInit(function ()
jQuery(".expand-control").each(function(){ jQuery(this).trigger("click");})


Step 3: Throw the feet up smile

Threw my feet up. Yay!

Thanks a lot.

I wish I could use an HTML macro, but this feature is not enabled and it seems to require system-administrator privilege. I sure wish Confluence was not so restrictive. Thanks for the tip.

Brilliant, Ben! I just tweaked the first line of your HTML to use a <button> element instead of an <a href> element:

<p align="center"><button name="toggleAll" id="toggleAll" type:"button">Expand/Collapse All Sections</button></p>

This makes a nifty centered button, and also doesn't alter the URL in the browser address bar. Everything otherwise works the same as the code you so kindly posted.

Thanks again!

Ack. Welcome to the neighborhood... I just realized there's a minor typo ("type:" instead of "type=") in the sample I posted yesterday. The sample still works, despite the typo, but it's annoying to an OCD type like myself. Here's an updated sample that uses the "=" sign consistently:

<p align="center"><button name="toggleAll" id="toggleAll" type="button">Expand/Collapse All Sections</button></p>

Thanks for listening.

Thanks for that Chung, however this seems different from the usual {expand} macro that comes with confluence. Do you know how to do the same thing with the {expand} macro?

I don't think so you can do so. IMO, the expand macro is used to expand 'part by part' - if you want to choose to expand all, you can put all information into one single expand (that defeats its purpose).

Yep I think you are right, that would defeat the purpose.
So in summary, I definitely cannot create my own user macro to do this?

0 vote

If you can edit the page then you can search the content without the need for any macro.

Suggest an answer

Log in or Join to answer
Community showcase
Jason Wong
Published Tuesday in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

406 views 6 16
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot