3 Answers
3

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.

If you run the latest version I'd create a new Scratch File of type JSON.
It's really easy, e.g. hit double shift, then search for new scratch file, select JSON as the language, paste your snippet and then use the shortcut that you usually use for formatting any file in intelliJ.