Translates Oniguruma regex patterns (used by Ruby, TextMate, VS Code) to native JavaScript RegExp with high accuracy.
Oniguruma-To-ES is a JavaScript library that translates Oniguruma regular expression patterns into native JavaScript RegExp. It solves the problem of using regexes written for Ruby, TextMate grammars (like those in VS Code and Shiki), or PHP in JavaScript environments, bridging syntax and behavioral gaps between the engines.
Developers working with TextMate grammars for syntax highlighting, those sharing regexes between Ruby/PHP and JavaScript codebases, and anyone needing to run Oniguruma-style regexes in JavaScript with high accuracy.
It provides near-perfect translation fidelity for real-world Oniguruma regexes, often outperforms WASM-based alternatives in speed and bundle size, and supports modern JavaScript targets with advanced emulation features unavailable in other translators.
👹 Convert patterns from Oniguruma (the regex flavor used by Ruby, TextMate grammars, etc.) to native JavaScript RegExp
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports ~99.99% of real-world Oniguruma regexes, accurately handling hundreds of syntax and behavioral differences, as tested on tens of thousands of TextMate grammar patterns.
Generated regexes run as native JavaScript, often faster than WASM-based alternatives like vscode-oniguruma, with a bundle size ~4% of it, reducing browser load times.
Outputs regexes compatible with ES2018, ES2024, or ES2025 targets, leveraging features like flag 'v' and flag groups for cleaner, more efficient patterns.
Accurately emulates complex Oniguruma features like atomic groups, possessive quantifiers, and recursion with identical behavior, even in extreme edge cases.
Allows precompiling regexes to eliminate runtime dependencies, and the tree-shakable EmulatedRegExp subclass minimizes bundle size for advanced features.
A few extremely rare Oniguruma features, such as overlapping recursions and named callouts, are not supported and throw errors, though they affect less than 0.01% of real-world regexes.
Advanced emulation requires the EmulatedRegExp RegExp subclass, which can complicate integration with code expecting native RegExp objects and may not be fully compatible in all environments.
Full feature support, like character class intersection, requires ES2024 or later, restricting use in older environments without upgrades or workarounds.
Numerous options like accuracy, target, and rules can be overwhelming for simple conversions and require careful tuning to avoid errors or suboptimal results.
Oniguruma-To-ES is an open-source alternative to the following products: