Tidy JavaScript in BBEdit

I’ve been poking around BBEdit 10 a bit, but it’s decidedly lacking in native support for things like tidying up javascript. So I added it.

It took me a bit of twiddling, so I thought I’d post it here.

  1. Grab my fork of jsbeautifier, originally written by Einar Lielmanis. It’s identical to the master branch, except it has a fix for a unicode issue with the text-stream BBEdit provides.
  2. Place this in ~/Library/Application Support/BBEdit/Text Filters/

It’s should now appear under the “Text” menu under “Apply Text Filter”. Set a hotkey for it if you’d like.

Presto! Tidy/Beautify javascript like magic. It can easily turn some minified nonsense into something semi-readable.

Kudos to Luke Andrews for setting me on the right track with his post about doing this in BBEdit 8.

Also of interest: Crisp’s JSON tidy script.

Edit Oct. 18th, 2011: I’ve updated the script to work with BBEdit 10.1. They changed how Text Filters accept input (stdin, used to be argv[0]). This script should still work with previous versions of BBEdit, but I don’t have a copy of BBEdit 10 to test it.

  1. ingeborg-jones reblogged this from objectivesea
  2. objectivesea posted this