How to format pasted JSON in IntelliJ / Android Studio

You are asking about two seperate things: scratch files and scratch buffers.

When you create a scratch file in IntelliJ you can choose the type of the file (e.g. JSON) that you want to create. Based on file's type, IntelliJ provides code formatting (use Code->Reformat code).

However, scratch buffers are just simple .txt files and the only formatting that can be used is the one associated to .txt format. So, if you put JSON into scratch buffer it won't get formatted with JSON type formatter.

I would encourage you to use scratch files instead of scratch buffers if you want JSON formatting.

More information can be found at IntelliJ's official page https://www.jetbrains.com/help/idea/2016.2/scratches.html.


I highlight the code and run Command Option L (a short-cut for the Code->Reformat Code menu).

On Windows use Ctrl Alt L.

Note that this only works if the code is well-formed JSON (clear any red squiggles).


choose from the menu : code -> reformat code

hotkey On Windows -:

CTRL + Alt + L

Important note- if you have sensitive information in your JSON- NEVER use online tools to parse or beautify it. because this will compromise your organization's and customer's information