Logs

JSON Log Line (Single-Line Object)

Match a single-line JSON object — typical of structured logging from services like slog, Bunyan, or Pino.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
^\{(?:[^{}]|\{[^{}]*\})*\}$

Raw source: ^\{(?:[^{}]|\{[^{}]*\})*\}$

How it works

^\{ anchors to an opening brace at start. (?:[^{}]|\{[^{}]*\})* matches any non-brace chars or one level of nested braces (so `{"a":{"b":1}}` matches but deeper nesting may not). \}$ anchors to the closing brace at end. Quick filter for log-line shape; pair with JSON.parse to validate fully.

Examples

Input

{"level":"info","msg":"started","port":8080}

Matches

  • {"level":"info","msg":"started","port":8080}

Input

{"event":"login","user":{"id":42}}

Matches

  • {"event":"login","user":{"id":42}}

Input

plain text log line

No match

Common use cases

  • Splitting mixed-format log streams (text vs JSON)
  • Routing JSON lines to a parser, text to a different sink
  • Pre-filter for log shippers (Vector, Fluentd, Filebeat)
  • Log-line shape validation in observability pipelines