PTPureToolkit
Code generationLocal-only

Nginx Access Log Regex Generator

Generate named capture groups for Nginx combined access logs locally in the browser.

This tool runs locally in your browser. Your input is not uploaded.

No uploadsNo server logsNo runtime APIsBrowser-only transforms

Prefilled local output

Copy the generated result or open the full tool to adjust inputs locally.

Sample log line

203.0.113.7 - - [27/Apr/2026:10:12:44 +0000] "GET /api/users?id=1 HTTP/1.1" 200 1234 "-" "Mozilla/5.0"

Regex and parsing snippets

JavaScript regex
/^(?<ip>\S+)\s+\S+\s+\S+\s+\[(?<timestamp>[^\]]+)\]\s+"(?<method>[A-Z]+)\s+(?<path>\S+)\s+HTTP\/[\d.]+"\s+(?<status>\d{3})\s+\S+(?:\s+"[^"]*")?(?:\s+"(?<userAgent>[^"]*)")?.*$/m

Python regex
r"^(?P<ip>\\S+)\\s+\\S+\\s+\\S+\\s+\\[(?P<timestamp>[^\\]]+)\\]\\s+\"(?P<method>[A-Z]+)\\s+(?P<path>\\S+)\\s+HTTP\\/[\\d.]+\"\\s+(?P<status>\\d{3})\\s+\\S+(?:\\s+\"[^\"]*\")?(?:\\s+\"(?P<userAgent>[^\"]*)\")?.*$"

Field table
| Field | Capture group |
| --- | --- |
| ip | `ip` |
| timestamp | `timestamp` |
| method | `method` |
| path | `path` |
| status | `status` |
| userAgent | `userAgent` |

Preview
Line 1: matched (ip=203.0.113.7, timestamp=27/Apr/2026:10:12:44 +0000, method=GET, path=/api/users?id=1, status=200, userAgent=Mozilla/5.0)

Python snippet
import re

pattern = re.compile(r"^(?P<ip>\\S+)\\s+\\S+\\s+\\S+\\s+\\[(?P<timestamp>[^\\]]+)\\]\\s+\"(?P<method>[A-Z]+)\\s+(?P<path>\\S+)\\s+HTTP\\/[\\d.]+\"\\s+(?P<status>\\d{3})\\s+\\S+(?:\\s+\"[^\"]*\")?(?:\\s+\"(?P<userAgent>[^\"]*)\")?.*$")
match = pattern.search(line)
if match:
    fields = match.groupdict()

JavaScript snippet
const pattern = /^(?<ip>\S+)\s+\S+\s+\S+\s+\[(?<timestamp>[^\]]+)\]\s+"(?<method>[A-Z]+)\s+(?<path>\S+)\s+HTTP\\/[\d.]+"\s+(?<status>\d{3})\s+\S+(?:\s+"[^"]*")?(?:\s+"(?<userAgent>[^"]*)")?.*$/m;
const match = line.match(pattern);
const fields = match?.groups ?? {};

Examples

Nginx Access Log Regex Generator

Generate named capture groups for Nginx combined access logs locally in the browser.

203.0.113.7 - - [27/Apr/2026:10:12:44 +0000] "GET /api/users?id=1 HTTP/1.1" 200 1234 "-" "Mozilla/5.0"

How it works

  1. Nginx Access Log Regex Generator focuses on extracting useful fields from Nginx combined access logs. The sample is prefilled so you can inspect the generated JavaScript and Python named capture groups immediately.
  2. This page is not a generic regex playground. It is tuned for log parsing workflows: select fields, generate a conservative extraction pattern, preview matches, and copy parser snippets into your own pipeline.
  3. Regex is best for stable line-oriented logs. If your application emits JSONL, parse JSON rather than matching text; if your log format varies by service version, treat the generated pattern as a starting point and add tests around real samples.

Limitations

  • This preset targets a common workflow and should be reviewed against your production environment.
  • Generated output is deterministic and local-first, but scheduler, log, or infrastructure dialects can vary.
  • Use the full parent tool when you need to adjust fields, ports, options, or sample inputs.

FAQ

Can this parse every Nginx combined access logs variant?

No. It generates a practical starter for common formats and shows warnings when manual adjustment is likely.

Are sample logs uploaded?

No. Generation and preview run locally in the browser.

Why use named capture groups?

Named groups make downstream parsing clearer because each extracted value is labeled by field name.

Related tools