how to compress code in .json file in IDEA?

Viewed 2429

IDEA makes the code in the .json file easier to read by adding appropriate line breaks and indentation, but I now want to ask IDEA to compress the json code to the extreme (without any indentation and line breaks), what should I do?

2 Answers

With IntelliJ IDEA 2021.2.1 (Ultimate Edition) at least, you can simply do:

Select-All, Edit > Join Lines

(Windows: ctrl-A, ctrl-shift-J with default mapping.) This places everyting on one line, so no indentation or linebreaks. However, there will be a after commas and before/after colons, if your code style is set for that.

IDEA doesn't have any built-in plugins for that. You can try the solutions available on the web, json-minify package, for example. It can then be set up as external tool or a file watcher to be run from the IDE

Related