Skip to content

Sort JSON Documents & Keys in VS Code

vscode sort json documents and keys

If you’re working with JSON documents, you may want to clean them up and sort all the object keys alphabetically.

This can make the files more readable and consistent, but it can also improve the compression and reduce the file size.

To sort the document, press CTRL + SHIFT + P type in ‘json sort document‘ and pick the JSON: Sort Document command.

This will sort the object keys alphabetically and remove any redundant whitespace characters.

🎥 Want to watch a video to supplement your reading? Check this out:


The JSON: Sort Document command comes with the JSON Language Features built-in extension.

So if you want to fiddle with your JSON settings, this is the place to start from.

Happy coding 😊

Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.