Skip to content

JSON Document Builder

The JSON Document Builder lets you take any text you already have in a document and wrap it inside a JSON object.
You simply give it a name (the key) and the document you want to include, and it returns a new document that contains the JSON string.

How it Works

When you drop a document into the Document input and type a word or phrase into the Key input, the component creates a JSON object that looks like this: json {“yourKey”:“content of the document”}

It then puts that JSON string into a new document.
If you feed it several documents at once, it will create one JSON document for each of them, each using the same key.

Inputs

  • Document: The document page whose text you want to turn into JSON.
  • Key: The name you want to give to the JSON field that will hold the document’s content.

Outputs

  • Documents: A document (or a list of documents) that contains the JSON string.
    This output can be passed to other components that need JSON data, such as a JSON parser or an API call.

Usage Example

  1. Add the component to your workflow.

  2. Connect a document (for example, a text file that says “Hello, world!”) to the Document input.

  3. Enter a key like greeting in the Key field.

  4. The component will output a document whose content is:

    {"greeting":"Hello, world!"}

    You can now feed this output into another component that expects JSON, such as a data upload or a chatbot prompt.

  • Document Loader – Pulls text from files or URLs into a document.
  • JSON Parser – Turns a JSON document into a structured format you can work with.
  • Text Splitter – Breaks long documents into smaller pieces before you build JSON.

Tips and Best Practices

  • Keep the key short and descriptive (e.g., summary, data, info).
  • Make sure the document content is plain text; formatting like tables may not serialize cleanly.
  • If you need multiple keys, run several instances of this component in parallel, each with a different key.

Security Considerations

The component works entirely on data that is already in your workflow; it does not send anything outside of Nappai.
Just be mindful that the JSON output will contain the raw text of your document, so avoid putting sensitive information in the input unless you have appropriate security controls in place.