Miss any of our Open RFC calls?Watch the recordings here! »


1.5.1 • Public • Published

esformatter-phonetic Build status

Esformatter plugin that renames variables and functions to pronounceable names

This was built to make reading obfuscated scripts easier (e.g. expand a single character variable to a full name, a -> apple). It was inspired by beautify-with-words but we wanted to leverage other esformatter plugins.

Getting Started

Install the module with: npm install esformatter-phonetic

Then, register it as a plugin and format your JS:

// Load and register our plugin
var esformatter = require('esformatter');
var esformatterPhonetic = require('esformatter-phonetic');
// Format our code
  'function hello() {',
    'var a = \'hello\';',
function hello() {
  var kusoce = 'hello';

Alternatively, load it via format or .esformatter:

  plugins: [


esformatter-phonetic exposes exports.transform for consumption by esformatter.


We allow for options via a phonetic key in your esformatter options.

  • Any option provided by phonetic (e.g. syllables, phoneticSimplicity)
  • baseSeed String|Number - Starting point for generating phonetic names.
    • If specified, we will start here and add 1 to the value (i.e. for numbers, it will increment. for strings, it will concatenate).
  • renameTopLevel Boolean - Flag to rename variables defined at top level or not
    • This is useful because in browser contexts, these variables are written to the window object.
    • By default, this is false (no rename occurs).
  • renamePerScope Boolean - Flag to rename variables on a per-scope basis
    • This supports using different names for lexical and block scoped variables.
    • This is useful for minified scripts that reuse names for variables to save space.
      • The downside is it loses potential shared context if the minifier did not leverage that optimization.
    • By default, this is false (common name used between scopes).


Walk the AST and rename variables that do not touch a with and have been declared.

Warning: This mutates the AST in place

  • ast AbstractSyntaxTree - Abstract syntax tree provided by esformatter


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.


Support this project and others by twolfson via gratipay.

Support via Gratipay


As of Nov 03 2014, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.


npm i esformatter-phonetic

DownloadsWeekly Downloads






Last publish


  • avatar