var to let / const — Free Online Tool

Replace the var keyword with let or const across your code, string, comment and regex aware so text like \. var to let / const is a free online tool from the ToolsRift JavaScript Tools collection. It runs entirely in your browser — nothing to install, no signup, and your data never leaves your device.

Loading var to let / const

How to use var to let / const

Paste your code, choose let or const as the replacement, then click Convert. Every var declaration keyword is replaced and the count is reported.

Frequently asked questions

Will it break strings containing 'var'?

No. The converter tracks string, comment and regex literals, so only the actual var keyword is replaced — text like "var" inside a string stays intact.

Should I choose let or const?

let is the safe default for variables that are reassigned. const is stricter; only pick it if you know none of the declarations are reassigned later.

Does it rename identifiers like 'variable'?

No. Replacement is whole-word only, so identifiers that merely contain the letters var, such as variable or avar, are left unchanged.

More JavaScript Tools

JavaScript Formatter
Beautify and format JavaScript code with proper indentation and structure for better readability
JavaScript Minifier
Minify JavaScript by removing whitespace, comments, and shortening variable names to reduce file size
JavaScript Validator
Validate JavaScript syntax and find errors with detailed line numbers and error messages
JSON to JS Object
Convert JSON data to JavaScript object literal syntax with proper formatting and structure
JS Object to JSON
Convert JavaScript object literals to valid JSON format with proper escaping and structure
Console.log Remover
Strip console.log, warn, error, info and debug statements from JavaScript without touching strings, comments or regex

← View all JavaScript Tools