Sublime Text: Automatically pretty format JSON and/or XML

I love the ability to quickly extend functionality in Sublime Text. For a while now I've been wanting a quick formatter for chunks of JSON/XML, so here's how I got it up and running on my Sublime Text 2.

Downloads

You'll need to download these files from my github repo:

Installation

To install these files, you'll have to move them to the right place first.

  • Open up Sublime Text (I'm using v2.0.2 at time of writing)
  • Click on "Preferences" in the menu
  • Click on "Browse Packages..."
  • Open the "User" folder
  • Move prettify_json.py and tidy_xml.py there
  • Check if "Main.sublime-menu" also exists in that folder
  • Open it in Sublime Text and paste in the following. If there is already some text in there, please merge them carefully. It shouldn't be too hard.

Now you should have to add it into the menu for easy access.

image

Update 19/05/15

Updated links to github raw source files. Fixes the issue where people were using "save files as" from this page and getting "greyed out menus".

Sources

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog