← Back to all regex patterns
Extraction
Low backtracking risk
Regex to Extract JSON Keys
A quick way to pull top-level and nested key tokens from JSON-like text during debugging or migration prep.
Regex
/"([^"]+)"\s*:/gTry this pattern
Matches current input
{"id": 1, "name": "Ada"}
2 matches found in the current text.
Passing examples
- {"id": 1, "name": "Ada"}
- "status" : "ok"
Failing examples
- [1,2,3]
- no-json-here
Code examples
JavaScript
const regex = /"([^"]+)"\s*:/g;
regex.test(input);Python
import re
pattern = re.compile(r""([^"]+)"\s*:")
bool(pattern.search(input))Go
re := regexp.MustCompile("\"([^\"]+)\"\\s*:")
matched := re.MatchString(input)