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

# JSON files integration

> Integrate with the JSON files document loader using LangChain JavaScript.

The JSON loader use [JSON pointer](https://github.com/janl/node-jsonpointer) to target keys in your JSON files you want to target.

### No JSON pointer example

The most simple way of using it is to specify no JSON pointer.
The loader will load all strings it finds in the JSON object.

Example JSON file:

```json theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
{
  "texts": ["This is a sentence.", "This is another sentence."],
  "nestedTexts": {
    "one": "This is a sentence nested in an object.",
    "two": "This is another sentence nested in an object."
  }
}
```

Example code:

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { JSONLoader } from "@langchain/classic/document_loaders/fs/json";

const loader = new JSONLoader("src/document_loaders/example_data/example.json");

const docs = await loader.load();
/*
[
  Document {
    pageContent: 'This is a sentence.',
    metadata: { source: 'example.json', line: 1 }
  },
  Document {
    pageContent: 'This is another sentence.',
    metadata: { source: 'example.json', line: 2 }
  },
  Document {
    pageContent: 'This is a sentence nested in an object.',
    metadata: { source: 'example.json', line: 3 }
  },
  Document {
    pageContent: 'This is another sentence nested in an object.',
    metadata: { source: 'example.json', line: 4 }
  }
]
*/
```

### Using JSON pointer example

You can choose which keys in your JSON object you want to extract strings from.

In this example, we want to only extract information from "from" and "surname" entries.

```json theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
{
  "1": {
    "body": "BD 2023 SUMMER",
    "from": "LinkedIn Job",
    "labels": ["IMPORTANT", "CATEGORY_UPDATES", "INBOX"]
  },
  "2": {
    "body": "Intern, Treasury and other roles are available",
    "from": "LinkedIn Job2",
    "labels": ["IMPORTANT"],
    "other": {
      "name": "plop",
      "surname": "bob"
    }
  }
}
```

Example code:

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { JSONLoader } from "@langchain/classic/document_loaders/fs/json";

const loader = new JSONLoader(
  "src/document_loaders/example_data/example.json",
  ["/from", "/surname"]
);

const docs = await loader.load();
/*
[
  Document {
    pageContent: 'LinkedIn Job',
    metadata: { source: 'example.json', line: 1 }
  },
  Document {
    pageContent: 'LinkedIn Job2',
    metadata: { source: 'example.json', line: 2 }
  },
  Document {
    pageContent: 'bob',
    metadata: { source: 'example.json', line: 3 }
  }
]
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/file_loaders/json.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
