CommonJS to ESM Converter
Convert require() to import statements
Source Input
Processed Output
What is the CommonJS to ESM Converter?
This converter rewrites CommonJS syntax to ESM: `const x = require('y')` becomes `import x from 'y'`, destructured requires become named imports, and `module.exports` assignments become `export default` or named exports.
Frequently Asked Questions (FAQ)
Q: What about dynamic requires?
Dynamic `require(variable)` cannot be statically converted; the tool leaves them as comments so you can switch to dynamic `import()` manually.
How to Use the CommonJS to ESM Converter
- 1Paste your input into the editor above — or start from the preloaded example.
- 2Adjust any options, then click Run to process instantly in your browser.
- 3Review the output panel, then copy, download, or save it as a reusable snippet.