Without proper line breaks and indentation, even moderately complex formulas are visually not well navigable in Google Sheets.

How can I pretty-print them? I know I can create a line break with Ctrl + Return and indent with Space but these changes are lost when leaving the cell.


3 Answers 3


This excel formula pretty-printer worked pretty good on my google spreadsheet:



=ifs(OR($I111="Elixir",$I111="Collectible",$I111="Lootbox"),,$AS111<='Items Statistics'!$H$22,1,$AS111<='Items Statistics'!$H$33,12,$AS111>'Items Statistics'!$H$33,12)


        $I111 = "Elixir",
        $I111 = "Collectible",
        $I111 = "Lootbox"
    $AS111 <= 'Items Statistics'!$H$22,
    $AS111 <= 'Items Statistics'!$H$33,
    $AS111 > 'Items Statistics'!$H$33,

I guess syntax is compatible for both spreadsheet and excel.


If you entered a formula let's say:


and then you changed your mind on its looks and want to look like:


all you need to do is change at least one lowercase of fx to uppercase (or vice versa):



also, you could just add an insignificant lock $ to any cell reference



CTRL + ENTER - for line break

  • Case change is a nice hack for the "whitespace changes are ignored" bug. It's still sad we have to do these workarounds, given Google's reputation of just not caring about bug reports …
    – tanius
    Commented Apr 23, 2019 at 15:35

Indeed, you can pretty-print your Google Sheets formulas with Ctrl + Return and Space. But there is a software bug in the current (2019-04) Google Sheets implementation that causes your whitespace changes to not be saved. A workaround is provided below.

Bug description

The bug is triggered like this:

  1. Google Sheets keeps an internal history about what formulas have been stored in a cell so far.

  2. When you change a formula, it is compared against this history, and whitespace differences are ignored.

  3. When it is found in the cell history, the old version of the formula (including its own whitespace formatting!) is used. When it is not found in the cell history, the formula you just entered is used.

In effect, whitespace-only changes are discarded when editing a formula.


For your whitespace changes to always be saved, your formula has to be always unique in its history (with whitespace differences ignored). You can achieve this by appending a do-nothing-operation to the formula and changing that with every change of your formula. Below are examples. You would choose a new line from the following list on each edit and use it at the end of your formula:

  • For number formulas, use the next line from this list for every new edit you make. It just adds zero, but always in a new way.

    + 0 * 1
    + 0 * 2
    + 0 * 3
  • For text formulas, use the next like from this list for every new edit you make. It appends the empty string always one more time than the last time.

    & REPT("",1)
    & REPT("",2)
    & REPT("",3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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