First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at http://jsbeautifier.org/, because it's what I found first. Downloads its file https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js

Second, download and install The Mozilla group's Java based Javascript engine, Rhino. "Install" is a little bit misleading; Download the zip file, extract everything, place js.jar in your Java classpath (or Library/Java/Extensions on OS X). You can then run scripts with an invocation similar to this

java -cp js.jar org.mozilla.javascript.tools.shell.Main name-of-script.js

Use the Pretty Print/Beautifier from step 1 to write a small shell script that will read in your javascript file and run it through the Pretty Print/Beautifier from step one. For example

//original code    
(function() { ... js_beautify code ... }());

//new code
print(global.js_beautify(readFile(arguments[0])));

Rhino gives javascript a few extra useful functions that don't necessarily make sense in a browser context, but do in a console context. The function print does what you'd expect, and prints out a string. The function readFile accepts a file path string as an argument and returns the contents of that file.

You'd invoke the above something like

java -cp js.jar org.mozilla.javascript.tools.shell.Main beautify.js file-to-pp.js

You can mix and match Java and Javascript in your Rhino run scripts, so if you know a little Java it shouldn't be too hard to get this running with text-streams as well.

Answer from Alan Storm on Stack Overflow
🌐
Kali Linux Tools
en.kali.tools
JS Beautifier - Penetration Testing Tools
sudo pip3 install jsbeautifier sudo pip3 install cssbeautifier js-beautify -h ... It is not necessary to install the program on a computer, the author has created a page that can beautify JavaScript code: https://beautifier.io/ ... KaliTools April 10, 2021 beautifier for source code, Computer ...
Main
JS Beautifier · JStillery · OllyDbg · Reverse · smali · TrID · UglifyJS · Valgrind · YARA · CaseFile · CutyCapt · dos2unix · Dradis · KeepNote · MagicTree · Metagoofil · Nipper-ng · pipal ·
All Programs
Tools for penetration testing and security audit · List of all available tools for penetration testing
Cheap VDS/VPS
Please click here if you are not redirected within a few seconds · You will be redirected in 3 seconds. If your browser does not automatically redirect you, please click here
🌐
Kali Linux Tools
en.kali.tools › all
python-jsbeautifier
Home / Tools / python-jsbeautifier · List of all available tools for penetration testing. Description: JavaScript unobfuscator and beautifier · Category: reversing webapp · Version: 1.15.1 · WebSite: https://github.com/beautify-web/js-beautify · Last Updated: 2024-02-21 ·
🌐
PyPI
pypi.org › project › jsbeautifier
jsbeautifier · PyPI
JavaScript unobfuscator and beautifier.
      » pip install jsbeautifier
    
Published   Feb 27, 2025
Version   1.15.4
Top answer
1 of 10
76

First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at http://jsbeautifier.org/, because it's what I found first. Downloads its file https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js

Second, download and install The Mozilla group's Java based Javascript engine, Rhino. "Install" is a little bit misleading; Download the zip file, extract everything, place js.jar in your Java classpath (or Library/Java/Extensions on OS X). You can then run scripts with an invocation similar to this

java -cp js.jar org.mozilla.javascript.tools.shell.Main name-of-script.js

Use the Pretty Print/Beautifier from step 1 to write a small shell script that will read in your javascript file and run it through the Pretty Print/Beautifier from step one. For example

//original code    
(function() { ... js_beautify code ... }());

//new code
print(global.js_beautify(readFile(arguments[0])));

Rhino gives javascript a few extra useful functions that don't necessarily make sense in a browser context, but do in a console context. The function print does what you'd expect, and prints out a string. The function readFile accepts a file path string as an argument and returns the contents of that file.

You'd invoke the above something like

java -cp js.jar org.mozilla.javascript.tools.shell.Main beautify.js file-to-pp.js

You can mix and match Java and Javascript in your Rhino run scripts, so if you know a little Java it shouldn't be too hard to get this running with text-streams as well.

2 of 10
64

UPDATE April 2014:

The beautifier has been rewritten since I answered this in 2010. There is now a python module in there, an npm Package for nodejs, and the jar file is gone. Please read the project page on github.com.

Python style:

$ pip install jsbeautifier

NPM style:

$ npm -g install js-beautify

to use it (this will return the beatified js file on the terminal, the main file remains unchanged):

$ js-beautify file.js

To make the changes take effect on the file, you should use this command:

$ js-beautify -r file.js

Original answer

Adding to Answer of @Alan Storm

the command line beautifier based on http://jsbeautifier.org/ has gotten a bit easier to use, because it is now (alternatively) based on the V8 javascript engine (c++ code) instead of rhino (java-based JS engine, packaged as "js.jar"). So you can use V8 instead of rhino.

How to use:

download jsbeautifier.org zip file from http://github.com/einars/js-beautify/zipball/master

(this is a download URL linked to a zip file such as http://download.github.com/einars-js-beautify-10384df.zip)

old (no longer works, jar file is gone)

java -jar js.jar  name-of-script.js

new (alternative)

install/compile v8 lib FROM svn, see v8/README.txt in above-mentioned zip file

./jsbeautify somefile.js

-has slightly different command line options than the rhino version,

-and works great in Eclipse when configured as an "External Tool"

🌐
JSON Formatter
jsonformatter.org › b9e805
kali
Use Auto switch to turn auto update on or off for beautification. It uses $.parseJSON and JSON.stringify to beautify JSON easy for a human to read and analyze. Download JSON, once it's created or modified and it can be opened in Notepad++, Sublime, or VSCode alternative. JSON Format Checker helps to fix the missing quotes, click the setting icon which looks like a screwdriver on the left side of the editor to fix the format. ... JSON Example with all data types including JSON Array.
🌐
Repology
repology.org › project › js-beautify › packages
js-beautify packages - Repology
Kali Linux Rolling main · 1.15.3 (1.15.3-1) Maintainer: havard.f.aasen@pfft.no · Category: misc · Link(s): Package pageok · Upstream homepageredir, no IPv6 · MacPorts · 1.15.4 · Summary: JS beautifier written in Python · Maintainer: nomaintainer@macports.org ·
🌐
GitHub
github.com › beautifier › js-beautify
GitHub - beautifier/js-beautify: Beautifier for javascript · GitHub
The configuration option names are the same as the CLI names but with underscores instead of dashes. For example, --indent-size 2 --space-in-empty-paren would be { indent_size: 2, space_in_empty_paren: true }.
Starred by 9K users
Forked by 1.4K users
Languages   JavaScript 42.8% | HTML 35.9% | Python 15.5% | Mustache 2.7% | Shell 2.6% | Makefile 0.3% | CSS 0.2%
🌐
Kali Linux Tools
en.kali.tools
JStillery - Penetration Testing Tools
It is not necessary to install the program on a computer, the author has created a page that can de-obfuscate JavaScript code: https://mindedsecurity.github.io/jstillery/ ... KaliTools April 10, 2021 beautifier for source code, Computer forensics, deobfuscation, JavaScript Reverse Engineering Comments Off on JStillery
Find elsewhere
🌐
Command Not Found
command-not-found.com › js-beautify
command-not-found.com – js-beautify
JavaScript unobfuscator and beautifier · Maintainer: Sebastien Delafond <[email protected]> Homepage: https://github.com/beautify-web/js-beautify · Section: misc · All systems · curl cmd.cat/js-beautify.sh · Debian · apt-get install jsbeautifier · Ubuntu · apt-get install jsbeautifier · Arch Linux · pacman -S node-js-beautify · Kali Linux ·
🌐
Linux packages
linux-packages.com › kali-linux › package › jsbeautifier
Complete Guide: Installing jsbeautifier on Kali Linux 2025
Architecture: all Provides: js-beautify (= 1.14.11-1) Depends: python3-jsbeautifier (>= 1.6.4-5), python3:any Size: 6060 SHA256: 99930a40077a01a1d332e9063cd7d9a48f208d884d0862274f61badf270eb5c5 SHA1: 1c60b01c81c469962c20a5e31668ee2654604a6a MD5sum: 8a093158d577ed805e211c32edec745a Description: JavaScript unobfuscator and beautifier Beautify, unpack or deobfuscate JavaScript, leveraging popular online obfuscators. Description-md5: Homepage: https://github.com/beautify-web/js-beautify Section: misc Priority: optional Filename: pool/main/p/python-jsbeautifier/jsbeautifier_1.14.11-1_all.deb ... Ubuntu Arch Linux Mint Fedora Kali Linux Debian openSuSE CentOS Oracle Linux Manjaro Rocky Linux AlmaLinux Amazon Linux Red Hat Enterprise Linux
🌐
OnWorks
onworks.net › home › software › linux › app js beautifier
JS Beautifier download for Linux
JS Beautifier download for Linux
JS Beautifier free download and run online in OnWorks over Linux online like Ubuntu, Fedora, Debian, Kali Linux
Rating: 4 ​
🌐
Beautifier
beautifier.io
Online JavaScript beautifier
Chrome, in case the built-in CSS and javascript formatting isn't enough for you: — Quick source viewer by Tomi Mickelsson (github, blog), — Javascript and CSS Code beautifier by c7sky, — jsbeautify-for-chrome by Tom Rix (github), — Pretty Beautiful JavaScript by Will McSweeney — Stackoverflow Code Beautify by Making Odd Edit Studios (github).
🌐
Kali Linux Tools
en.kali.tools
de4js - Penetration Testing Tools
JS Beautifier (84.9%) Binwalk (54.6%) Detect It Easy (54.6%) usbrip (RANDOM - 4.6%) KaliTools April 18, 2021 beautifier for source code, Computer forensics, deobfuscation, JavaScript, obfuscation Reverse Engineering Comments Off on de4js · Comments are Closed ·
🌐
OnWorks
onworks.net › home › software › app js beautifier
JS Beautifier
JS Beautifier
JS Beautifier free download and run online in OnWorks over Linux online like Ubuntu, Fedora, Debian, Kali Linux
Rating: 4 ​
🌐
Miloserdov
miloserdov.org
JS Beautifier - Ethical hacking and penetration testing
Alex May 3, 2020 deobfuscation, JavaScript, JS Beautifier, JStillery, obfuscation, UglifyJS, web browsers, web-sites, webapps Reverse Engineering One Comment » · Telegram notifications about new articles on Miloserdov.org: t.me/miloserdov_org · Anonymity, data encryption and anti-forensics · Exploitation · Hardware · Improving security · Information Gathering · IT Forensics · Kali Linux ·
🌐
Installati.one
installati.one › home › how to install jsbeautifier on kali linux
How To Install jsbeautifier on Kali Linux | Installati.one
June 1, 2023 - In this tutorial we learn how to install jsbeautifier package on Kali Linux using different package management tools: apt, apt-get and aptitude.
🌐
Install Lion
installlion.com › home › installion: how to install jsbeautifier on kali linux 2017.1
Installion: How To Install jsbeautifier On Kali Linux 2017.1
September 4, 2019 - http://installion.co.uk/kali/kali/main/j/jsbeautifier/install/index.htmlJavaScript unobfuscator and beautifier obfuscators.Kali Linux 2017.1misc1.6.4-6 · sudo apt-get install jsbeautifier · Which will install jsbeautifier and any other packages on which it depends.
🌐
Installati.one
installati.one › home › how to install node-js-beautify on kali linux
How To Install node-js-beautify on Kali Linux | Installati.one
June 1, 2023 - In this tutorial we learn how to install node-js-beautify on Kali Linux. ... This little beautifier will reformat and reindent bookmarklets, ugly JavaScript, unpack scripts packed by Dean Edward??s popular packer, as well as deobfuscate scripts processed by javascriptobfuscator.com.
🌐
Kali Linux
pkg.kali.org › news › 563054 › python-jsbeautifier-11411-1-imported-into-kali-rolling
python-jsbeautifier 1.14.11-1 imported into kali-rolling
April 24, 2023 - It has been imported from Debian: https://tracker.debian.org/pkg/python-jsbeautifier -- More information about python-jsbeautifier: http://pkg.kali.org/pkg/python-jsbeautifier