You ask about two different things: files with scratches and buffers from scratch.
When creating a scratch file in IntelliJ, you can choose the type of file (for example, JSON) that you want to create. Based on the file type, IntelliJ provides code formatting (use Code-> Reformat code).
However, buffers from scratch are just plain .txt files, and the only format you can use is the one that is associated with the .txt format. So, if you put JSON in the buffer from scratch, it will not be formatted with formatting like JSON.
I would recommend using scratch files instead of buffers from scratch if you want to format JSON.
Further information can be found on the official IntelliJ page at https://www.jetbrains.com/help/idea/2016.2/scratches.html .
source share