> For the complete documentation index, see [llms.txt](https://docs.graphlinq.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlinq.io/dev-tooling/blocks/json/convert-to-json.md).

# Convert To JSON

The Convert To JSON block in the GraphLinq IDE is a versatile tool that enables developers to convert various data types into JSON format. JSON (JavaScript Object Notation) is a widely used data interchange format that is human-readable and easy for machines to parse. This block is valuable when developers need to prepare data for external APIs, databases, or other systems that require JSON-formatted data.

The Convert To JSON block accepts different types of data as input, such as strings, numbers, arrays, or objects. This means developers can pass various data structures to the block for conversion to JSON format.

The block's output is a JSON representation of the input data. The output is a JSON object that can include nested properties and values, depending on the structure of the input data.

### Use Case

Imagine a scenario where a graph receives data from multiple sources, such as a user inputting values, data fetched from an API, and calculations performed by the graph. Before sending this data to an external service or saving it in a database, the Convert To JSON block can be used to format the data into a unified JSON structure, ensuring consistent data representation across different sources.

### Example

Let's consider a simple example where a graph receives two numeric inputs, "temperature" and "humidity," from different blocks. These inputs might represent real-time weather data. The Convert To JSON block can then take these inputs and convert them into a JSON object in the following format:

```json
{
  "temperature": 25,
  "humidity": 60
}
```

In this example, the Convert To JSON block converts the individual temperature and humidity values into a single JSON object.

*Note:* It is essential to ensure that the input data provided to the Convert To JSON block is compatible with JSON formatting. Data types that are not natively supported by JSON, such as circular structures or functions, may cause errors during the conversion process.

The Convert To JSON block significantly simplifies the process of converting diverse data types into a standardized JSON format. It empowers developers to seamlessly prepare data for consumption by external systems and services, enabling efficient data exchange and interoperability within the graph and beyond.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.graphlinq.io/dev-tooling/blocks/json/convert-to-json.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
