Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Need help with a script to find and replace text in multiple confluence pages


I have been assigned a task to find and replace few words in confluence pages and I came across script runner as a very useful tool. I will be very thankful if anyone in this group can help me with a script that will help me to accomplish my task of finding and replacing text at the page level in confluence.
Thanks in advance,

2 answers

1 accepted

0 votes
Answer accepted
Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 18, 2021

Hi @Jagadeesh Welcome to the Atlassian Community!

This blog on scriptrunner site already have a script that you can download and modify as per your requirement. The example script works on a single space, but you can modify the code to loop through all your confluence spaces and its pages and perform search/replace as per your use case.

Hi Kishan,

Thank you very much for your quick reply. Yes, I am using the sample script shared by the Script runner trial version tool, but it is throwing errors and I need someone who has already used this script to help me in debugging or modifying the current script. 

The sample script shows how to modify within a table in confluence page, I want to modify text within a page in confluence. I am not sure what code elements to use. if you have an idea how to modify the script, please do message me at this mail id I will be very thankful for helping me out.


M Jags

Kishan Sharma
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 20, 2021

Hi Jagadeesh,

I will also suggest posting this question to Atlassian Developer Community so that you will get better solutions from the developers working on such scripting activities. I will also post here in case I able to get this to work.

Hi Kishan,

Thanks for the suggestion. Sure, I will post in the developer community too. I have another 10 days before the trial version expires. In the meanwhile, if you know any groovy script developers please suggest their mail ids. I will try connecting with them.

Hi Jagadeesh,

Here's what your script might look like if you wanted to find and replace text anywhere on particular Confluence pages:

import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.sal.api.component.ComponentLocator
import org.jsoup.Jsoup

def pageManager = ComponentLocator.getComponent(PageManager)
def spaceManager = ComponentLocator.getComponent(SpaceManager)

def targetSpace = spaceManager.getSpace("SAL")

pageManager.getPages(targetSpace, true).each { page ->
log.debug "Inspecting page ${page.title}"
def body = page.bodyContent.body
body = body.replace('Human Resources', 'HR')
pageManager.saveNewVersion(page) { pageObject ->



@Tiffany Wortham Is this possible with script runner for cloud?

Hi cami!

I'm sure this is possible with ScriptRunner for Confluence Cloud, but your script will look pretty different because you'll have to use the Confluence Cloud Rest API.

Hey Tiffany. The Confluence Cloud REST API documentation states that connect apps cannot access the rest resource necessary to perform that action. Isn't ScriptRunner a connect app?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events