> ## Documentation Index
> Fetch the complete documentation index at: https://docs.js-confuser.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rename Labels

> Renames labeled control-flow statements, and removes unnecessary labels. **Enabled by default.**

* Option name: `"renameLabels"`

* Option values: `true/false/Function`

***

### Input / Output

This example showcases how `Rename Labels` transforms the code. Try it out by changing the input code and see changes apply in real-time.

```js title="Input.js" lines interactive-mode="obfuscate" theme={null}
// Input.js
A: for (var i = 0; i < 10; i++) {
  if (i % 2 === 0) {
    continue A;
  }

  B: {
    console.log(i);
    break B;
  }
}

// Output.js
for (var U608Lvf = 0; U608Lvf < 10; U608Lvf++) {
  if (U608Lvf % 2 === 0) {
    continue;
  }
  OrWu4Q: {
    console.log(U608Lvf);
    break OrWu4Q;
  }
}
```

***

### Custom Implementation

#### `options.renameLabels(labelName)`

Control which label names are changed. Returns a `boolean`.

| Parameter   | Type     | Description                            |
| ----------- | -------- | -------------------------------------- |
| `labelName` | `string` | The label name proposed to be changed. |

***

### Usage Example

The provided code example will obfuscate the file `input.js` and write the output to a file named `output.js`.

```js title="Usage Example" lines theme={null}
import JSConfuser from "js-confuser";
import {readFileSync, writeFileSync} from "fs";

// Read input code
const sourceCode = readFileSync("input.js", "utf8");
const options = {
  target: 'browser',
  renameLabels: true,
};

JSConfuser.obfuscate(sourceCode, options).then((result)=>{
  // Write output code
  writeFileSync("output.js", result.code);
}).catch(err=>{
  // Error occurred
  console.error(err);  
});
```

***

#### Enabled In

* [High Preset](/presets/high): Yes
* [Medium Preset](/presets/medium): Yes
* [Low Preset](/presets/low): Yes
