Skip to content
Owais Khan Software Reviews

W3C Traceparent Header Parser

Paste a traceparent header to split it into its four fields and check it against the W3C Trace Context rules — or generate a valid one to test with. Tracestate is parsed too.

Everything runs locally: what you paste never leaves your browser.

Parse and validate a traceparent header

Valid traceparent (version 00, sampled)

    Version · 1 byte

    00

    Trace ID · 16 bytes

    4bf92f3577b34da6a3ce929d0e0e4736

    Parent (span) ID · 8 bytes

    00f067aa0ba902b7

    Trace flags · 1 byte

    01

    Trace flags
    Bit Flag Set Meaning
    0 sampled Yes the caller may have recorded this trace
    1 random No the trace-id’s right 7 bytes are random (Trace Context Level 2)

    2 tracestate members: rojo, congo

      Generate a traceparent

      curl

      curl https://example.com/api \
        -H "traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01" \
        -H "tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE"

      Raw HTTP

      GET /api HTTP/1.1
      Host: example.com
      traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
      tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE

      JavaScript (OpenTelemetry)

      import { context, propagation } from '@opentelemetry/api';
      
      // Writes traceparent (and tracestate) for the active span into `headers`.
      const headers = {};
      propagation.inject(context.active(), headers);

      How the header is read

      A traceparent is four fields separated by dashes. The example above is the one used in the W3C specification: version 00, a 16-byte trace ID shared by every span in the request, the 8-byte ID of the span that made this call, and a flags byte whose lowest bit says whether the caller sampled the trace. Version 00 headers are exactly 55 characters.

      Validation follows the specification rather than being lenient: IDs must be lowercase hex, neither ID may be all zeros, and version ff is forbidden. A header from a future version is still read the way the spec requires — the first four fields are parsed and anything after them is kept — so a newer header does not break older tooling.

      A W3C trace context online decoder and traceparent header generator

      Most people arrive needing a W3C trace context online decoder to find out why a trace is broken, or a traceparent header generator to inject a known trace ID into a test request. Both are here, along with a tracestate header parser that checks the vendor list for the mistakes that get it silently dropped: uppercase keys, duplicate keys, a stray equals sign, or more than 32 members.

      Where these rules come from

      The field lengths, the lowercase-hex rule, the invalid all-zero IDs, the forbidden version and the forward-compatibility behaviour are from the W3C Trace Context Recommendation. The random flag is from Trace Context Level 2. OpenTelemetry uses this header as its default propagation format.

      Frequently asked questions

      What is the format of a W3C traceparent header?
      Four lowercase-hex fields joined by dashes: version-traceid-parentid-flags. For the current version, 00, that is 2 + 32 + 16 + 2 hex characters plus three dashes, exactly 55 characters — for example 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01. The trace ID identifies the whole distributed trace and the parent ID identifies the calling span.
      What does the sampled flag 01 vs 00 mean?
      The last field is a byte of bit flags, and bit 0 is “sampled”. 01 means the caller may have recorded this trace, so downstream services are encouraged to record their spans too; 00 means it was not sampled. It is advice, not a command — a service can make its own sampling decision. Trace Context Level 2 adds bit 1, the “random” flag, set as 02 or 03.
      How do I generate a valid traceparent header for testing?
      Use the generator above: it produces a version-00 header with a random 16-byte trace ID and 8-byte parent ID from your browser’s cryptographic random source, with the sampled bit on or off. Paste it into a curl -H "traceparent: …" call, and every service that speaks Trace Context will attach its spans to that trace ID.
      What is the difference between traceparent and tracestate?
      traceparent is the vendor-neutral part every tracer understands: which trace this is and which span called you. tracestate carries vendor-specific data alongside it, as up to 32 comma-separated key=value pairs, with the most recent vendor on the left. A service that does not recognise a tracestate entry must still pass it on unchanged.
      Can a traceparent use uppercase hex, or an all-zero ID?
      Neither is valid. The specification defines the ID fields as lowercase hex, and many tracers reject uppercase outright. An ID of all zeros is explicitly invalid, as is version ff. A receiver that finds an invalid traceparent is supposed to ignore it and start a new trace, which is why a single wrong character silently breaks trace continuity instead of raising an error.
      Is the header I paste sent anywhere?
      No. The parser runs entirely as a small script inside this page; what you paste never leaves your browser, and there is no upload, no API call and no analytics here. That is enforced rather than promised: this site’s test suite scans the shipped HTML for every browser API capable of sending data off the page and fails the build if it finds one.