
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
pretty-regex
Advanced tools
Print regular expressions with syntax highlighting in the terminal. Useful for debugging, visually inspecting and understanding complex regex patterns.
Print regular expressions with syntax highlighting in the terminal. Useful for debugging, visually inspecting and understanding complex regex patterns.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save pretty-regex
import { parse } from 'pretty-regex';
// Parse a regex pattern into a tree
const tree = parse(/foo(bar)+[a-z]/);
// Get the parsed AST
console.log(tree);
// Get colorized output
console.log(tree.print());
Parse a regular expression pattern into a tree structure that can be used to create colorized output.
Params
regex {RegExp|String}: The regex pattern to parse.Returns
{Object}: Returns a tree with nodes for each part of the regex.Example
import { parse } from 'pretty-regex';
// Parse a string pattern
const tree = parse('foo[a-z]');
// Or pass a RegExp instance
const tree = parse(/foo[a-z]/);
// Customize colors with your own print function
// or use the built-in tree.print() method
console.log(tree.print());
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Jon Schlinkert
Copyright © 2025, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on April 18, 2025.
FAQs
Print regular expressions with syntax highlighting in the terminal. Useful for debugging, visually inspecting and understanding complex regex patterns.
We found that pretty-regex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.