Menu

JavaScript Identifier Renamer

Rename variables, functions, and parameters to random gibberish using real AST parsing. Scope-aware — does not touch string contents or object properties. Safe obfuscation for JS code.

Ready
Name Style:
How this works: Parses your JavaScript with Acorn (real AST parser), walks every scope, and renames declarations plus their references. Strings, comments, and object property names are preserved by default.
Risky options: "Globals" renames top-level var/function — this can break code that expects them on window. "Object Properties" renames obj.prop — only use if you control both sides.
Original JavaScript 0 chars
Renamed Output 0 chars
Understanding Identifier Renaming

What Is Identifier Renaming?

Identifier renaming is the process of replacing meaningful variable, function, and parameter names in source code with short, meaningless identifiers. For example:

// Before
function calculateTotalPrice(items) {
  let totalPrice = 0;
  for (const item of items) {
    totalPrice += item.price * item.quantity;
  }
  return totalPrice;
}

// After
function a(b) {
  let c = 0;
  for (const d of b) {
    c += d.price * d.quantity;
  }
  return c;
}

This is one of the most common obfuscation techniques in the JavaScript world. Popular minifiers like Terser, esbuild, and UglifyJS all perform identifier renaming by default. Combined with whitespace removal, it makes code compact and much harder to understand.

Why Rename Identifiers?

  • Reduce file size. A long name like calculateTotalPrice becomes a, saving bytes. This is the primary motivation for minifiers.
  • Raise reverse-engineering cost. Meaningful names are a roadmap for understanding code. Renaming removes that roadmap.
  • Protect intellectual property. Name changes make it harder for competitors to understand your algorithms at a glance.
  • Bypass naive scrapers. Some scrapers look for keywords like function init or var token. Renaming breaks these patterns.

Why AST Parsing Matters

The naive approach — regex search-and-replace — breaks code. Consider:

const name = "Alice";
console.log("Hello, " + name);
console.log(obj.name);

A regex replacing name would incorrectly rename:

  • The "name" inside obj.name — this is a property, not a variable
  • Any string literal that contains name
  • Identifiers in comments

An AST parser like Acorn understands the difference. It knows that the first name is a variable declaration, the second is a reference to that variable, and obj.name is a property access. Only the first two are renamed.

Scope Awareness

JavaScript has block scoping. Two variables with the same name in different scopes are different variables:

let x = 1;
function foo() {
  let x = 2;  // different x
  return x;
}
console.log(x);  // still 1

A scope-aware renamer renames each scope's variables independently. This tool builds a complete scope tree from the AST, then renames each declaration with a unique name.

What This Tool Protects

  • String literals — never touched
  • Comments — preserved as-is
  • Object property names — preserved (unless you enable the risky option)
  • Global variables — preserved (unless you enable the risky option)
  • Keywords — never renamed

What This Tool Cannot Do

  • It cannot encrypt your code. The output is still readable JavaScript — just with weird names. Anyone can rename them back.
  • It cannot hide string literals. If your code contains "API_KEY_123", that string is still visible.
  • It cannot protect against determined reverse engineers. Renaming is a speed bump, not a wall.
  • It cannot recover the original names. The mapping is shown once, but the original code is gone.

Name Styles

StyleExampleBest For
Shorta, b, c, aa, abSmallest output size
Hex_0xa1b2, _0xc3d4Classic obfuscator look
RandomxK3mN, pQ7vRHardest to pattern-match
UUID_a1b2c3d4Maximum uniqueness

Best Practices

  • Always test after renaming. Run the renamed code in a browser and check for errors.
  • Keep the mapping. If you need to debug the renamed code, the mapping shows you which name became what.
  • Do not enable "Globals" unless necessary. Renaming top-level var and function can break code that expects them on window.
  • Use with a minifier. Run this tool, then minify the output for smaller files.

Frequently Asked Questions

Does this tool execute my code?
No. It parses your code as text and renames identifiers. The code is never run.
Will renamed code still work?
In most cases, yes. But some code relies on function names (via Function.prototype.name), class names, or top-level globals. Always test after renaming.
Is my code uploaded to your server?
No. Everything runs in your browser using the Acorn parser. Your code never leaves your device.
Why is this JavaScript-only?
Because reliable browser-based AST parsers only exist for JavaScript (Acorn) and closely related languages. Python, PHP, Java, etc. have parsers that only work on server-side.
What is the mapping export?
It shows which original name became which new name, so you can debug renamed code. The mapping is shown once — save it if needed.
Can I undo the renaming?
Not automatically. Save the original code before renaming. If you have the mapping, you could manually reconstruct it, but the tool does not offer automatic reversal.

Related Tools

External Resources