data_uri
Convert payloads to data: URIs or parse existing data URIs into media type, parameters, and decoded data. Supports base64 or percent encoding.
Instructions
Build a data: URI from a payload, or parse one into its parts (RFC 2397).
action=build (needs data, read via input_format): wraps it as
data:[media_type][;base64],<payload>; base64=true base64-encodes the
payload, else it is percent-encoded. action=parse (needs uri): returns
media_type (defaulting to text/plain when absent), the ;k=v parameters,
is_base64, and the decoded data rendered via output_format.
Example: data_uri("build", media_type="text/plain", data="hi") -> uri
"data:text/plain;base64,aGk="
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 'build' wraps a payload into a data: URI (needs `data`); 'parse' splits a URI into its parts (needs `uri`). | |
| media_type | No | MIME type for build, e.g. 'text/plain' or 'image/png'. Default None omits it. | |
| data | No | Payload to wrap (action=build), decoded via `input_format`. Default None. | |
| base64 | No | For build: true base64-encodes the payload (adds ';base64'), false percent-encodes it. Default true. | |
| uri | No | The 'data:...' URI to parse (action=parse). Default None. | |
| input_format | No | How build `data` is decoded to bytes; default 'text'. | text |
| output_format | No | How parsed payload is rendered (text=UTF-8 | hex | base64); default 'text'. | text |