Code Formatter & Minifier
Beautify or minify HTML, CSS, JavaScript and SQL snippets with two-space indentation, right in your browser, then copy the result.
Beautify or minify HTML, CSS, JavaScript and SQL snippets with two-space indentation, right in your browser, then copy the result.
Minified or copied-from-somewhere code is hard to read: a whole stylesheet on one line, an HTML fragment with no indentation, a SQL query pasted from a log. This page gives such snippets a quick, readable layout, or squeezes them back onto as few lines as possible. It has four tabs, HTML, CSS, JavaScript and SQL, each with its own Format / Beautify and Minify rules. Output always uses two-space indentation. It is meant for quick clean-ups of snippets you want to read, review or paste into a message, not as a replacement for the formatter or build tool in your project.
All four formatters are small hand-written routines that run in your browser. They work on characters and patterns rather than a full parser for each language, which keeps them fast and dependency-free but also means they do not validate your code.
br, img, input and meta keep it level. Minify removes line breaks and whitespace between tags and collapses repeated spaces.{, ; and }, with declarations indented inside their block. Minify also strips /* */ comments, spaces around braces, colons, commas and semicolons, and the last semicolon before each }.;, { and }. Quoted strings and template literals are copied untouched, and regular-expression literals are detected so that a / inside them is not misread. Minify removes comments and whitespace around punctuation and operators.Always review the output before using it, and keep your original. These routines can change the meaning of code in the cases below.
// line comments do not survive formatting well. Use semicolons and /* */ comments, or a real formatter such as Prettier.// on a line is removed, including the rest of a URL such as "https://…". Use a proper minifier like Terser or esbuild for production files.data: URLs. The SQL formatter also upper-cases and splits keywords that appear inside quoted strings, and does not add extra indentation for subqueries.pre, textarea and script elements, and SVG tags written as <path/> are treated as opening tags, which shifts the indentation.No. Formatting and minifying are plain JavaScript functions on this page. Your code is not sent to a server and is not stored in your browser.
Not on this page; the formatters always use two spaces. Most editors can convert indentation after you paste the result.
No. Invalid code is formatted as best it can be without any warning. A missing brace, for example, simply leaves the indentation off by one level.
Yes. The SQL Formatter page has syntax highlighting and more formatting options for queries; this page's SQL tab is the quick version.