Find a tool

↑↓ navigate Enter open

Use a task word when you do not know the exact name.

JavaScript Formatter and Minifier

Local only

Format JavaScript into readable source with Prettier, or minify it with Terser for a smaller delivery file. KitLumi processes up to 2 MB in your browser without uploading or executing your code. Select Script or ES module to match the source before minifying.

Reviewed · Updated · Free to use · No account required

JavaScript Formatting and Minification Workspace
Input0 chars
Output
Parsing and conversion run locally in this tab.

Formatting and minification target different artifacts

Use Prettier output for review, debugging, and source control. Use Terser output only as a tested deployment artifact. Neither mode executes the pasted program, bundles imports, resolves dependencies, or validates runtime behavior.

How do you use it?

  1. Choose Format JavaScript for readable source or Minify JavaScript for a smaller delivery artifact.
  2. Select Script for classic browser or Node.js source, or ES module when the code uses import and export syntax.
  3. Paste JavaScript no larger than 2 MB, run the operation, then review and download javascript-output.js.

Worked example

Compare the same function in both modes

Input

const tools=["HTML","JavaScript"];function findTool(name){return tools.find((tool)=>tool===name)??null}

Output

Format JavaScript:
const tools = ['HTML', 'JavaScript'];
function findTool(name) {
  return tools.find((tool) => tool === name) ?? null;
}

Minify JavaScript:
const tools=["HTML","JavaScript"];function findTool(o){return tools.find(n=>n===o)??null}

With the current options, the source is 103 UTF-8 bytes, formatted output is 120 bytes, and minified output is 89 bytes. These are this example’s results, not a general compression ratio.

Common errors and fixes

SymptomLikely causeFix
Formatting or minification reports an unexpected token.The source is incomplete, contains unsupported proposal syntax, or is TypeScript rather than JavaScript.Correct the first syntax error and remove TypeScript-only annotations; this tool intentionally targets JavaScript and JSX parsed by Babel.
An import or export statement fails during minification.The source type is set to Script even though the input is an ES module.Select ES module before minifying source that contains import, export, or module-level semantics.
Minified code behaves differently in the application.The code depends on function names, Function.prototype.toString(), stack formatting, top-level globals, or nonstandard side effects that conflict with optimizer assumptions.Keep readable source under version control, test the minified artifact in the target runtime, and disable minification for incompatible code.

Should you beautify source or minify a delivery file?

For the worked example below, the original is 103 UTF-8 bytes, Prettier output is 120, and Terser output is 89. Readable formatting can increase size; compression depends on the actual program. Checked on 2026-10-15 with Prettier 3.9.9 and Terser 5.51.2.

ModeUse it forWhat remains unchecked
Format JavaScriptReading, review and consistent source layoutImports, types and runtime behavior
Minify JavaScript · ScriptA compact classic-script artifactApplication behavior and optimizer assumptions
Minify JavaScript · ES moduleSource with import/export and module semanticsDependency resolution, bundling and runtime behavior

Important behavior of JavaScript Formatter

Minification can change function and variable names, remove unused code, and expose assumptions about reflection or side effects; regression-test the generated artifact before deployment.

Standards and implementation references

Frequently asked questions about JavaScript Formatter

What is the difference between beautifying and minifying JavaScript?

Beautifying adds consistent layout for reading and review. Minifying removes optional syntax and can shorten local names. Keep readable source and test the minified artifact in the application that will run it.

Why do import or export statements fail in Script mode?

Choose ES module when minifying a file that uses import or export. Script mode is intended for classic scripts; changing the mode does not bundle imported dependencies.

Can I paste TypeScript into this JavaScript formatter?

Use the TypeScript Formatter for type annotations and interfaces. This JavaScript tool does not compile TypeScript or type-check a project.

Does successful formatting prove that my program works?

No. Parsing and formatting do not check missing imports, network responses, DOM availability, application logic, or runtime behavior. Neither mode executes your pasted code or uploads it to KitLumi.

What changed?

Checked the same source through Prettier and Terser, published exact outputs and UTF-8 byte counts, and clarified source-mode and runtime-validation limits.

Who maintains this tool?

KL
KitLumi EngineeringKitLumi Engineering maintains tool behavior, privacy disclosures, examples, and automated tests.