Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Aura Console JanitorNew to Visual Studio Code? Get it now.
Aura Console Janitor

Aura Console Janitor

Sai Patil

|
2 installs
| (0) | Free
Removes console.log and tidies whitespace in Salesforce Aura files on save or on demand, with a verify preview, CSV reports and a package.xml of the components you worked on.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Aura Console Janitor

A janitor for Salesforce Aura code. It removes console.log statements, including commented-out ones such as //console.log(response);. When you save a file with Cmd+S, it cleans the file automatically. The right-click command shows a verify preview before it changes anything. It can also keep CSV reports, a whitespace report (how much there was before and how much was cleaned) and a package.xml of the components you worked on.

How to use

Right-click a file or folder in the Explorer (or in the editor) and choose Remove console.log (preview first).

  1. The preview appears in the Aura Console Janitor output panel: one row per component, with the number found, the line numbers and the result. A file without any console.log shows "Not found".
  2. A message asks whether to apply the changes. Click Apply changes (write) and confirm.
  3. Check the result with git diff.

For an Aura component, right-click its folder to clean the controller, helper and renderer together.

Or use a paths file, one path per line:

  1. Ctrl+Shift+P (Mac: Cmd+Shift+P) and run Aura Console Janitor: Open or create the paths file. Add your paths.
  2. Run Aura Console Janitor: Verify to preview.
  3. Run Aura Console Janitor: Write to apply, then check git diff.

A line in the paths file can be a full file path, an Aura component folder, or just the component name.

Aura only

This extension is for Aura. Files inside an lwc folder are skipped: the preview shows "Skipped (LWC not supported)" and the file is never changed. Cleanup on save also ignores lwc folders.

Clean automatically on save (on by default)

This is on by default. To turn it off, run Aura Console Janitor: Turn cleanup on save ON or OFF (Command Palette), or set auraConsoleJanitor.removeOnSave to false. Every time you save a .js file inside an aura folder with Cmd+S (Windows and Linux: Ctrl+S), its console.log statements are removed and the whitespace is tidied (see below) before the file is written. The status bar shows what was done.

  • Only manual saves. Auto-save is ignored, so a log you have just typed is not deleted. Set auraConsoleJanitor.alsoOnAutoSave to true to include auto-save.
  • Which files. auraConsoleJanitor.onSaveFolders lists the folder names that count. The default is ["aura"]. Use ["*"] for every .js file. Files in lwc and __tests__ folders are always skipped.
  • For the whole team. The settings follow the extension, so everyone who installs it gets the same defaults. To fix different values for one project, put them in that project's .vscode/settings.json.
  • Debugging. While it is on, your own console.log lines are removed on save too. Turn it off while you debug, or use console.warn or console.error for logs you want to keep.
  • First save of an old file. The whitespace cleanup can change many lines the first time you save an existing file, so git diff shows a lot of changes. Check the first one before you commit.
  • Undo. Cmd+Z brings the removed lines back in the editor.
  • A file that cannot be parsed, or that fails the safety check, is saved unchanged. The reason is written to the output panel.

Whitespace cleanup (on by default)

All three are on by default. They apply to the right-click command, the paths file and cleanup on save. Set any of them to false in Settings to switch it off.

Setting What it does
auraConsoleJanitor.tidy.spacesToTabs Converts every four leading spaces into a tab
auraConsoleJanitor.tidy.trailingSpaces Removes trailing spaces and tabs
auraConsoleJanitor.tidy.blankLines Collapses several blank lines into one

Text inside template literals and multi-line strings is never touched, so no string value can change. Line endings (LF or CRLF) are kept.

Reports (CSV and package.xml)

Turn on auraConsoleJanitor.saveReport and/or auraConsoleJanitor.savePackageXml. These files are kept, always with the same names:

File Content Needs
console-removal-report.csv Every statement with its line number saveReport
console-removal-whitespace.csv Whitespace cleanup per file: before, cleaned, after, with a TOTAL row saveReport
console-removal-package.xml package.xml with the AuraDefinitionBundle members savePackageXml
console-removal-components.csv One row per component savePackageXml

The whitespace report

console-removal-whitespace.csv has one row per file, and a TOTAL row at the end. For each file it shows:

Group Columns
Before lines, characters, lines indented with 4+ spaces, lines with trailing spaces, extra blank lines
Cleaned lines changed to tabs, trailing-space lines cleaned, extra blank lines removed, whitespace characters removed
After the same five numbers after the cleanup (what is left)
Other lines deleted together with console.log

"Extra blank lines" are blank lines that come right after another blank line. Lines inside template literals and multi-line strings are not counted, because they are never touched. The numbers are also there when a tidy option is switched off: the Before columns still show how much whitespace the file has, and the Cleaned columns are 0.

After a console.log is removed, the blank lines around it can end up next to each other. The Cleaned numbers include those, so they can be a little higher than the Before numbers.

The list grows as you work

The files are built from a running list. Every right-click run and every save of an Aura file adds its file to the list, or updates it if it is already there. A file is never listed twice, and an older component is not dropped when you work on a new one. A saved file that had nothing to change is listed too, with the status "Saved (nothing to remove)", so the package.xml holds every component you saved.

A later save that finds nothing to change does not overwrite the numbers of an earlier cleanup of that file. So the whitespace report keeps the real "before" numbers of the first cleanup, even if you save the same file again.

To empty the list and begin again, run Aura Console Janitor: Start a new report (clear the list). Your code is not touched. A hidden helper file (.aura-console-janitor-state.json) in the same folder holds the list. Do not edit it.

They are saved in Documents/AuraConsoleJanitorReports in your home folder, unless you choose another folder with auraConsoleJanitor.reportFolder:

Value Example
Full path /Users/you/Desktop/reports
Home folder ~/Desktop/reports
Relative to the project reports (this folder is created inside the project)

After a right-click run, a message with an Open folder button appears. You can also run Aura Console Janitor: Open the report folder at any time.

What it removes and what it keeps

Removed Kept
console.log(...) on one line or several lines console.warn, console.error and other console methods
//console.log(...) and block-comment logs Normal comments such as // console.log is slow
A log that is the only body of an if, replaced by {} Text inside strings
A log inside an arrow function without braces (listed for manual removal)

Settings

Setting Meaning
auraConsoleJanitor.removeOnSave Clean a file when you save it. On by default.
auraConsoleJanitor.onSaveFolders Folder names for cleanup on save. Default ["aura"].
auraConsoleJanitor.alsoOnAutoSave Include auto-save. Off by default.
auraConsoleJanitor.tidy.spacesToTabs / trailingSpaces / blankLines Whitespace cleanup. On by default.
auraConsoleJanitor.reportFolder Where reports are saved. Empty means Documents/AuraConsoleJanitorReports.
auraConsoleJanitor.saveReport Keep the statement report and the whitespace report. Off by default.
auraConsoleJanitor.savePackageXml Keep console-removal-package.xml and console-removal-components.csv. Off by default.
auraConsoleJanitor.pathsFile Paths file to use. Empty means paths.txt in the project root.
auraConsoleJanitor.nodePath Optional. Use your own node instead of the one built into VS Code.

Safety

  • Verify never changes a file. Write asks for confirmation first.
  • Before saving, the tool checks that nothing except the console statements and whitespace was changed, and that no string or template text changed. If the check fails, the file is not changed.
  • Everything runs locally. No code is sent anywhere. No npm packages are needed.

Limits

  • Aura only. LWC files (inside an lwc folder) are skipped.
  • Works on JavaScript files only (not .cmp, .html or .css).
  • Folders are processed one level deep (a component folder).
  • A log with a function call inside, such as console.log(helper.get(x)), is removed together with that call.
  • A log inside an arrow function without braces is not removed. It is listed as "Kept" so you can remove it by hand.

The tool uses the open-source acorn parser (MIT licence), bundled unmodified.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft