A Go port of the awesome jsbeautifier tool
Latest commit 2520a80 Dec 6, 2014 @ditashi Update README.md


jsbeautifier-go Travis build status

A golang port of the awesome jsbeautifier tool

This is a port of the awesome jsbeautifier tool to golang.

Granted this is a very basic and naive attempt since this is one of my first takes with golang.

Current state

Implemented most of the original features from jsbeautifier (missing features are listed in the following section).

What doesn't work

  • Unpacking & Deobfuscation (and with that code eval)
  • Reading from stdin


  1. Finish implementing features to match the current state of JsBeautifier
  2. Unpacking & Deobfuscation


go get && go run main.go test.js


From within the source folder run: go test ./... or use something like goconvey


    jsbeautifier [options] PATH


    --indent-size=SIZE              Indentation Size [default: 4]

    --indent-char=CHAR              Indentation Char [default: space]
    --brace-style=STYLE             Brace Style (expand, collapse, end-exapnd or none) [default: collapse]
    --outfile=OUTPUTFILE            Output results to a file [default: stdout]
    -z --eval-code                  Eval JS code (dangerous!)
    -f --keep-function-indentation  Keep original function indentation
    -t --indent-with-tabs           Use tabs to indent
    -d --disable-preserve-newlines  Don't preserve newlines
    -P --space-in-paren             Use spaces in parenthesis
    -E --space-in-empty-paren       Use spaces in empty parenthesis
    -j --jslint-happy               Keep JSLint happy :)
    -a --space_after_anon_function  Use spaces after anonymous functions
    -x --unescape-strings           Unescape strings
    -X --e4x                        Parse XML by e4x standard
    -n --end-with-newline           End output with newline
    -w --wrap-line-length           Wrap line length
    -i --stdin                      Use stdin as input
    -h --help                       Show this screen
    --version                       Show version


You are free to use this in any way you want, in case you find this useful or working for you but you must keep the copyright notice and license. (MIT)