CloudEvents Decoder with data_base64 Support – Free

Paste a structured-mode CloudEvents JSON object and this CloudEvents decoder formats it and decodes the data_base64 field into readable text, added to the output as decodedData.

How to use the Cloud event decoder tool

  1. Paste one event as JSON into the CloudEvent JSON box, or select Example to load a sample with a Base64 payload.
  2. Select Decode event to parse and format it.
  3. Read the formatted event in the Result box. If data_base64 was present, the decoded text appears in a decodedData field at the end.
  4. If the payload is not UTF-8 text, decodedData shows Binary and the byte count.
  5. Select Copy to copy the formatted JSON for a bug report or test fixture.

CloudEvents JSON format in brief

CloudEvents is a CNCF specification that gives events from different systems a common envelope. Version 1.0 requires four context attributes: specversion, id, source and type. Optional ones include time, subject, datacontenttype and dataschema.

In the JSON event format the payload goes in one of two members. A producer uses data when the payload is JSON or text that can sit directly in the document. It uses data_base64 when the payload is binary, such as Protobuf, Avro or an image, because JSON cannot carry raw bytes. A well-formed event has one or the other, not both.

What this CloudEvents decoder does with your input

The text is parsed as JSON and must be an object whose specversion is a string. That is the only attribute check. The tool does not verify that id, source and type exist or that the version is one it knows, so it is an inspector, not a conformance validator.

When data_base64 is a string, its value is Base64-decoded. Standard and URL-safe alphabets are both handled, padding may be missing, and whitespace is ignored. The bytes are then read as strict UTF-8. Valid text is added as decodedData, and anything else is summarized as Binary with its length in bytes. Events without data_base64 are simply re-indented with two spaces.

Input:
{"specversion":"1.0","id":"evt-42","type":"com.example.order.created","source":"/orders","datacontenttype":"application/json","data_base64":"eyJvcmRlciI6NDJ9"}

Result:
{
  "specversion": "1.0",
  "id": "evt-42",
  "type": "com.example.order.created",
  "source": "/orders",
  "datacontenttype": "application/json",
  "data_base64": "eyJvcmRlciI6NDJ9",
  "decodedData": "{\"order\":42}"
}

Details to know before you rely on the output

The result is meant for reading during debugging. A few behaviors follow from that.

  • decodedData is always a string. A payload that is itself JSON is shown with escaped quotes and is not expanded into nested objects.
  • decodedData is an addition for display. It is not part of the CloudEvents specification, so do not send the output back as an event.
  • Only structured mode is supported. For a binary-mode HTTP message, where attributes travel in ce- headers, build a JSON object from the headers and body first.
  • A batch, which is a JSON array of events, is rejected. Paste one event object at a time.
  • The event is re-serialized by the browser, so integers above 9,007,199,254,740,991 can lose precision.

Where CloudEvents with Base64 payloads appear

Knative Eventing, Azure Event Grid and Google Cloud Eventarc deliver events in this envelope, and many Kafka, NATS and webhook integrations adopt it so consumers can route on type and source without parsing the body. You will meet data_base64 mostly when a producer serializes its payload with Protobuf or Avro, or forwards a file.

Frequently asked questions

What is data_base64 in a CloudEvent?

It is the member of the JSON event format that carries a binary payload as a Base64 string. A producer uses it in place of data when the bytes are not JSON or text. Consumers decode it and interpret the bytes according to datacontenttype.

Why does decodedData say Binary?

The decoded bytes are not valid UTF-8, so they are not text. The payload is probably Protobuf, Avro, compressed data or an image. The tool reports the byte count. To inspect the bytes, copy the data_base64 value into the Base64 to Hex tool.

Does this tool validate my event against the CloudEvents spec?

No. It only requires a JSON object with a string specversion. Missing required attributes, wrong attribute types and unknown versions are not reported. Use an SDK or schema validator when you need a conformance check.

Is the event sent to a server?

No. Parsing and Base64 decoding run in your browser with JavaScript. Nothing in the event is transmitted by this page.

Why do I get a JSON syntax error?

The input is not valid JSON. Common causes are a log prefix before the opening brace, single quotes, or a truncated message. Trim the text to the object itself.

Related tools