Obfuscate JavaScript source

Apply a simple text-based pass that shortens JavaScript names, removes comments, and collapses whitespace.

freeworks offlinenothing uploaded
ToolJavaScript Obfuscator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The source is scanned with regular expressions to rename simple declarations, remove line and block comments, and collapse whitespace. It is text substitution rather than an AST transform, so syntax and scope are not fully understood.

  • Short names reduce visual readability but are not encryption.
  • The conservative pass avoids a compiler dependency and needs review.

Worked example

Obfuscate variable names
Rename variables to make JavaScript harder to read
Input
											const apiKey = 'secret123';
function fetchData(url) {
  return fetch(url);
}
										
Output
												const _a = 'secret123'; function _b(url) { return fetch(url); }
											

When to use this

Demo bundles, browser experiments, and size comparisons use this lightweight pass.

Edge cases

  • Text inside a string or comment can be renamed by the regex.
  • Property names and references outside simple patterns remain unchanged.
  • Shadowed variables can be changed incorrectly because scope is not modeled.