Home / JavaScript tools / JavaScript pretty print

JavaScript Pretty Print

Paste JavaScript and read it as clean, indented code with line numbers and syntax colors. Copy the plain text when you are done.

Result


  

Pretty print for reading

Pretty printing means laying code out so that a person can read it. This page does that and then shows the result like a code editor would, with a line number on each line and colors for keywords, strings, numbers, comments and regular expressions. It is made for reading and checking code, rather than for editing it.

The colors

  • Keywords such as function, return, const and if.
  • Strings and template literals.
  • Numbers.
  • Regular expressions.
  • Comments.

When it helps

  • You copied a script from a web page or a network response and it is one long line.
  • You need to point to a line, for example in a bug report or code review.
  • You want to check what a snippet does before you run it.

Copying the code

The Copy result button copies plain text without the line numbers, so you can paste it straight into your editor. Download gives you a .js file. For very long code, the display shows the first 4000 lines and a note, but copy and download always include everything.

Same engine, different view

The layout comes from the same engine as the JavaScript formatter, so all of its options are here too: indent, line breaks, blank lines, object layout and quotes. Heavily compressed code reads best with the beautifier settings. If you only want smaller files, see the JavaScript minifier.

Frequently asked questions

What does pretty print mean?

It means reformatting code with indentation and line breaks so it is easy to read. This page adds line numbers and syntax colors on top.

Do the line numbers get copied?

No. Copy result gives you plain code only, without line numbers.

Can it pretty print minified JavaScript?

Yes. Paste it in and it is expanded. Variable names stay short, because minifiers remove the original names.

Is there a size limit?

There is no fixed limit, but the colored view shows the first 4000 lines for speed. Copy and download include all lines.