> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Files and Structured Data

> Move between files, text, objects, JSON, YAML, and data URLs without losing the intended format.

WorkflowDog treats files, strings, and structured values as different data
types. Keep them distinct until a system boundary requires a conversion.

## Know what you have

| Value              | Contains                                              | Typical use                                          |
| ------------------ | ----------------------------------------------------- | ---------------------------------------------------- |
| **File**           | A name, MIME type, encoding, and base64-encoded bytes | Uploads, attachments, downloads, images, PDFs        |
| **String**         | Text                                                  | Prompts, messages, CSV text, JSON text, HTML         |
| **Object or List** | Structured workflow data                              | API payloads, records, branching, property selection |
| **Data URL**       | A string containing a MIME type and base64 data       | Embedded browser or API content                      |

Changing a filename does not convert bytes, and serializing an object does not
create a File. Use an explicit conversion action so the boundary is visible on
the canvas.

## Create and download files

Use [Create Text File](/reference/actions/files/create-text-file) when the
content already exists as a String. Supply the complete filename, including an
extension. To deliver structured data as a file, convert the value to JSON,
create `report.json` from that text, then upload, attach, or return the
resulting File.

The filename extension is used to infer the MIME type when recognized.

Use [Download File from URL](/reference/actions/files/download-from-url) to
retrieve a public resource. You can provide a filename or let the action derive
one from the URL path. It uses the response's content type when available and
fails for non-success responses.

<Warning>
  Download File from URL blocks local, internal, and private network addresses.
  It is for public resources, not for reaching services inside a private
  network.
</Warning>

## Rename without converting

[Rename File](/reference/actions/files/rename) returns a copy with a new name
while preserving its bytes and MIME type.

Renaming `invoice.png` to `invoice.jpg` still leaves PNG image data inside the
file and preserves the original MIME type. Use a format-specific conversion
action when the content itself must change.

## Convert files to and from data URLs

[Convert File to Data URL](/reference/actions/files/file-to-data-url) creates a
String in this form:

```text theme={null}
data:image/png;base64,iVBORw0KGgo...
```

This is useful when HTML or an API requires embedded content. Base64 increases
the representation's size, so prefer a File when the receiving action accepts
one.

[Convert Data URL to File](/reference/actions/files/data-url-to-file) performs
the reverse operation. Its input must use the exact
`data:MIME_TYPE;base64,DATA` form. The output is named
`converted.EXTENSION`, with the extension derived from the MIME type.

<Note>
  A normal `https://` URL is not a data URL. Download it with **Download File
  from URL** instead.
</Note>

## Parse JSON text

[Parse JSON](/reference/actions/core/json-parse) converts a valid JSON String
into its native value: an Object, List, String, Number, Boolean, or `null`.

```json theme={null}
{
  "customer": {
    "id": "cus_123",
    "active": true
  },
  "tags": ["new", "priority"]
}
```

After parsing, select the properties downstream actions need. See
[Connect Data](/building/connect-data#select-part-of-an-object) for property
outputs.

Malformed JSON causes the action to fail. JSON requires double-quoted strings
and does not allow comments or trailing commas.

## Serialize values as JSON or YAML

[Convert to JSON](/reference/actions/core/json-stringify) serializes a
workflow value as JSON text. Enable pretty formatting for human-readable
output; compact output is usually better for API requests or storage.

[Convert to YAML](/reference/actions/core/yaml-stringify) emits YAML using
two-space indentation. Its **Use references?** option represents repeated
objects with YAML anchors and aliases. Leave references off when every section
should be standalone and easy to copy.

Serialization is useful at an external boundary:

For example, build an Object, convert it to JSON, then create `payload.json`
from the serialized text.

<Tip>
  Do not serialize only to parse the value again in the next node. Connect the
  original Object or List directly and preserve its types.
</Tip>

## Validate structured data

[Validate JSON Schema](/reference/actions/utilities/validate-json-schema)
checks any value against a JSON Schema and returns:

* **Is Valid**, a Boolean;
* **Errors**, a list containing every validation error found; and
* the original validated value or top-level property outputs, depending on the
  schema.

For an object schema, the node exposes properties declared under the schema's
top-level `properties`. Connect **Is Valid** to
[Route Value](/reference/actions/control/demux) or a **Conditional** meta
control before using those values. One safe pattern is:

1. Parse the JSON text.
2. Validate the parsed value against the schema.
3. Connect both the validated object and **Is Valid** to **Route Value**.
4. Continue processing from **If True**.
5. Use **If False** to record the validator's **Errors**.

Validation does not coerce types. The String `"18"` does not satisfy an
`integer` schema. It also does not strip extra properties, and property outputs
remain the supplied values even when validation fails.

<Warning>
  An ordinary schema mismatch returns **Is Valid: false**. Malformed JSON or an
  invalid schema fails the action itself. Handle those as separate failure
  cases.
</Warning>

## Choose the right conversion

<AccordionGroup>
  <Accordion title="I have an object and an API expects JSON text">
    Use **Convert to JSON**. If the API action accepts a structured body
    directly, connect the Object instead.
  </Accordion>

  <Accordion title="I have JSON text and need individual fields">
    Use **Parse JSON**, then select properties from the resulting value.
  </Accordion>

  <Accordion title="I have text that must become an attachment">
    Use **Create Text File** and give it the correct filename extension.
  </Accordion>

  <Accordion title="I have a public URL and need a File">
    Use **Download File from URL**.
  </Accordion>

  <Accordion title="I have a File but the destination expects embedded data">
    Use **Convert File to Data URL**.
  </Accordion>
</AccordionGroup>
