Loading…

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
JS Comment Remover
Remove line and block comments from JavaScript while preserving URLs and comment syntax inside strings, with optional JSDoc keep
JS Import Sorter
Sort and group ES module import statements alphabetically, separating external packages from internal relative imports
JavaScript Obfuscator
Basic JavaScript obfuscation with variable renaming and string encoding to protect code
ES6 to ES5 Converter
Convert modern ES6+ arrow functions and syntax to ES5-compatible JavaScript for legacy browsers
JS to TypeScript
Add TypeScript type annotations to JavaScript functions for better type safety and IDE support
Regex Tester
Real-time regular expression tester with match highlighting, groups, and detailed match information

← View all JavaScript ToolsBrowse all 1,100+ tools →