Advertisement

Pattern library / Strings & Text

Regex to Match JSON Property Names

Matches a JSON property name in double quotes. Useful for log parsing, schema validation, and extracting keys from JSON-like text.

The pattern
^"[A-Za-z_][A-Za-z0-9_]*"$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
"name"Matchsimple keyTry →
"user_id"Matchsnake_case keyTry →
"_private"Matchleading underscoreTry →
"123"No matchstarts with digitTry →
"has space"No matchspace not allowedTry →
nameNo matchmissing quotesTry →

Where to use it

JavaScript

const re = /^"[A-Za-z_][A-Za-z0-9_]*"$/;
re.test('"user_id"');  // true

Python

import re, json
re.match(r'^"[A-Za-z_][A-Za-z0-9_]*"$', '"user_id"')

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.