FormattersLesson 3Free preview
JSON Minifier
This lesson is part of Web Developer Tools · All levels
Summary
JSON Minifier removes spaces, tabs, and new lines that are outside the string, so that JSON becomes as short as possible. The result is similar in meaning to the smooth version, but smaller in size and more economical when delivered over the network. The minifier must not delete spaces within the string value because the space is part of the data. Use minified versions for production, while neat versions remain in the repository.
Key points
- Delete the whitespace outside the string, not inside the string value
- The payload size is reduced so that data transfer is more efficient
- The structure and value of JSON remain the same after the minify
- JSON must be valid before it can be properly minimized
- Save the easy-to-read version in the repository and minify the results for deployment
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.