When debugging a complex regular expression—whether you're parsing user emails, server transaction logs, or customer database records—having a visual tester is essential.
But there is a major security catch.
Most popular online regex tools stream your raw test data straight to remote backends for compilation. If you are testing patterns against real production logs, you are leaking sensitive user data and credentials to third-party databases.
To prevent this data vulnerability, we built a 100% secure, browser-isolated JS Regex Match Visualizer on tools.kandz.me.
👉 Try the Live Tool: https://tools.kandz.me/regex-visualizer
đź§ How It Works Under the Hood
This visualizer runs strictly within your browser's private memory sandbox. Here is the technical architecture that allows it to securely render and inspect matches on the fly:
1. Dynamic Local Compilation
We compile your regex inputs using standard browser JavaScript engines, bypassing external server API runs completely. The regex is instantiated with selected modifier flags:
let flags = '';
if (flagGlobal) flags += 'g';
if (flagIgnoreCase) flags += 'i';
if (flagMultiline) flags += 'm';
const regex = new RegExp(pattern, flags);
2. HTML-Escaped Highlight Tokenizer
Rendering visual highlights securely is critical. If we injected raw matches directly as HTML, it would trigger Cross-Site Scripting (XSS) errors.
To ensure complete safety, our parser first sanitizes the entire source string. It then calculates the exact offset coordinates of each match, wraps the matched indices in highlighted <span> blocks, and trusts the final computed string:
// Safely wraps matched coordinate slices
result += `<span class="bg-indigo-100 rounded cursor-pointer border-b-2" onclick="window.dispatchRegexMatchClick(${idx})">${escapeHtml(m.fullText)}</span>`;
3. Global Event Dispatching
We mapped dynamic click listeners onto individual highlighted DOM spans. Clicking any highlighted match in your browser triggers a global scoped callback that immediately inspects and displays that match's specific capture groups ($1, $2, etc.) in the active panel—making large data array audits incredibly fast.
🛠️ Keep Your Log Audits Secure
Protect your database dumps and user logs from external API tracking. Try the visualizer on your local machine:
đź”— Link to Tool: https://tools.kandz.me/regex-visualizer
Top comments (0)