Cool JavaScript Beautifier

By | November 10, 2021

Beautify or format your JavaScript code with this free JavaScript Beautifier online tool.

JavaScript

Output




HTML <style>, <script> formatting:

Javascript Beautifier Tool

Enter your Ugly, minified, messy, or obfuscated Javascript (JS) into the text area above to have it beautified up and made pretty. The editor above also contains helpful line numbers and syntax highlighting. There are many options to tailor the beautifier to your personal formatting tastes.

When do you use Javascript Beautifier

Often when writing Javascript (JS) your indentation, spacing, and another formatting can become a bit disorganized. It is also common for multiple developers to work on a single project who have different formatting techniques. This tool is helpful for making the formatting of a file consistent. It is also common for Javascript (JS) to be minified or obfuscated. You can use this tool to make that code look pretty and readable so it is easier to edit.

Beautifying is a process that makes your code more readable and maintainable, but it can also make any code look better. There is a big difference between a nicely formatted code and a messy one, but why is there a big difference?. The messy code becomes difficult to read and the logic is harder to impossible to grasp.

Sample JavaScript Code

function StringStream(t){this.pos=0,this.string=t}StringStream.prototype={done:function(){return this.pos>=this.string.length},peek:function(){return this.string.charAt(this.pos)},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(t){var s=this.string.charAt(this.pos);if("string"==typeof t)var i=s==t;else var i=s&&t.test?t.test(s):t(s);return i?(this.pos++,s):void 0}};

Sample Output Code

// Demo code

function StringStream(string) {
  this.pos = 0;
  this.string = string;
};

StringStream.prototype = {
  done: function() {return this.pos >= this.string.length;},
  peek: function() {return this.string.charAt(this.pos);},
  next: function() {
    if (this.pos < this.string.length)
      return this.string.charAt(this.pos++);
  },
  eat: function(match) {
    var ch = this.string.charAt(this.pos);
    if (typeof match == "string") var ok = ch == match;
    else var ok = ch && match.test ? match.test(ch) : match(ch);
    if (ok) {this.pos++; return ch;}
  }
};