It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Editing Source Code in Confluence

We recently had to upgrade Confluence to 5.9.1 because of a bug in indexing that is supposed to be fixed in this version.  But then we discovered that  the source code editor we were using no longer works with that version. I used that editor to format our templates and create elements for CSS to format. We MUST have access to the html. Although we are allergic to plugins with a price, we may have to pay to find one that works. It's that important.  Does anyone have any suggestions....please....

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Well, if you are willing to pay for it, I wouldn't turn it down, but there is an option for changing the source code without the Source Editor plugin.  It takes a few manual steps, but it's not so hard.

  1. On the page you want to change, go to the ••• menu and choose "View Storage Format"
  2. Copy and paste it into your favorite editor (I like Notepad++)
  3. Make the changes you want
  4. (NO LONGER NECESSARY) Remove all line breaks (i.e. make it so the whole thing is on one line).  In Notepad++, you can do a search and replace for \r\n (don't forget to choose "Extended") and make sure that the replace box is empty and choose "replace all"
  5. (NO LONGER NECESSARY) Do another search and replace and replace all " characters with \"
  6. Copy that and paste it over the <PASTE CODE HERE> part of this script (but leave the backticks `` intact):

    var newBodyText = `<PASTE CODE HERE>`;
        url: contextPath + "/rest/api/content/" + AJS.params.pageId + "?,version,ancestors",
        success: function(response) {
   = newBodyText;
            response.version.number += 1;
                contentType: 'application/json',
                type: 'PUT',
                url: contextPath + "/rest/api/content/" + AJS.params.pageId,
                data: JSON.stringify(response),
                success: function(response) {
                error: function(response) {
  7. While you are on the page you want to change the code for, open up the browser console (Often by pressing F12 or Shift+Ctrl+I).
  8. Paste that new script into the browser console, and press enter.
  9. If everything went well, you should see Success!, and if you refresh the page, you should see your changes.

This would actually work in Confluence Cloud as well.

EDIT: Modern browsers let you make multiline strings using backticks (`) which makes steps 4 and 5 unnecessary.

Nice, simple en to the point

Can't give this enough up-votes

Our organization offers a paid plugin, Source Editor for Confluence to edit the source of Confluence pages. We support both server and cloud. 

Let me know if you have any questions or feedback about the plugin.


This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Thursday in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

268 views 0 12
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