Is a way to convert all headings X into headings X + 1 or heading X - 1 in Google Documents?

E.g. I have a Google document with 100 headings 2: is there any way to convert them into headings 1 or 3 in a convenient fashion (i.e. without having to manually change the heading for each 100 of them)?


With this little script you can change the headings automatically. Especially useful when the different headings are convoluted.


function changeHeading() {
  var pars = DocumentApp.getActiveDocument().getBody().getParagraphs();  
  for(var i in pars) {
    var p = pars[i], h = p.getHeading(), d = DocumentApp.ParagraphHeading;
    switch(h) {
      case h.HEADING1:
      case h.HEADING2:


First all paragraph types are collected. Then these are checked for headings. If a heading matches Heading 1, then it's changed to Heading 2 etc.

Add this script in your Google Document under Tools > Script editor.... Press the "bug" button to authenticate the script.

| improve this answer | |
  • The above script has a bug in it. It changes all existing Heading 1 to Heading 2 and it changes all existing heading 2 to Heading 1, when it should be Heading 3. This version just swaps Heading 1 and Heading two instead of pushing everything down a level. – August Mohr Sep 22 '19 at 23:04
  • @AugustMohr I thought the OP meant heading 1 or 3. You can alter the script anyway you like to see for yourself. – Jacob Jan Tuinstra Sep 23 '19 at 5:33

After a couple of days of more 'normal' activity levels no better offer yet so I suggest:

Change "Heading 2" to the required style and then "Update 'Heading 2' to match.

This does not add or subtract from the Heading reference number but at least allows easy propagation across the 100 headings to be changed, by altering one only.

| improve this answer | |

I figured out a work-around when I was copying text from another Google Doc that already had h1, h2, etc that didn't fit into the target document.

If you highlight text, in the right-click menu, there is "Select all matching text". This selects all text with the same formatting in the document. For instance, if you select an H2 text, it will select all H2 texts. If you select bolded, italicized text, it will select all bolded, italicized text.

First, what I needed to do was cut the copied text and paste it into a new document. That's because I didn't want to select H1s in the whole document; I just want the H1 in the copied text. So I needed the copied text alone in another document.

Then, in that new document, I selected an H1, right-clicked, and selected "Select all matching text". This highlighted all the H1s in the copied text. I changed them to H3 with ctrl+alt+3, which is what I needed them to be in the new document. Same deal with H2s, demoting them to H4s.

Then I cut and pasted the demoted text back into the target document. Done!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.