---
schema_version: "1"
id: 8c34fc72d520706fe9fcba1c9be6e6405df0d992247367054f5478b1ab1677e0
title: data import tree
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/data/cli_reference_data_import_tree.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_data_import_tree.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4f1897e20e13c4c5e7313da4e9544e6da38f86f3baeb0b5743d6da1c7d07d748
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# data import tree

Import data from one or more JSON files into an org.

## Description for data import tree

The JSON files that contain the data are in sObject tree format, which is a collection of nested, parent-child records with a single root record. Use the "sf data export tree" command to generate these JSON files.

If you used the --plan flag when exporting the data to generate a plan definition file, use the --plan flag to reference the file when you import. If you're not using a plan, use the --files flag to list the files. If you specify multiple JSON files that depend on each other in a parent-child relationship, be sure you list them in the correct order.

## Aliases for data import tree

`force:data:tree:import`

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;api&#8209;version</code> | N/A | **Type:** Value<br><br>Override the api version used for api requests made by this command |
| <code>&#8209;&#8209;files</code> | <code>&#8209;f</code> | **Type:** Value<br><br>Comma-separated and in-order JSON files that contain the records, in sObject tree format, that you want to insert. |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;plan</code> | <code>&#8209;p</code> | **Type:** Value<br><br>Plan definition file to insert multiple data files.<br><br>Unlike when you use the `--files` flag, the files listed in the plan definition file **can** contain more then 200 records. When the CLI executes the import, it automatically batches the records to comply with the 200 record limit set by the API.<br><br>The order in which you list the files in the plan definition file matters. Specifically, records with lookups to records in another file should be listed AFTER that file. For example, let's say you're loading Account and Contact records, and the contacts have references to those accounts. Be sure you list the Accounts file before the Contacts file.<br><br>The plan definition file has the following schema:<br><br><ul><li>items(object) - SObject Type: Definition of records to be insert per SObject Type</li><li>sobject(string) - Name of SObject: Child file references must have SObject roots of this type</li><li>files(array) - Files: An array of files paths to load</li></ul> |
| <code>&#8209;&#8209;target&#8209;org</code> | <code>&#8209;o</code> | **Type:** Value<br>**Required**<br><br>Username or alias of the target org. Not required if the `target-org` configuration variable is already set. |

## Examples for data import tree

Import the records contained in two JSON files into the org with alias "my-scratch":

```shell
sf data import tree --files Contact.json,Account.json --target-org my-scratch
```

Import records using a plan definition file into your default org:

```shell
sf data import tree --plan Account-Contact-plan.json
```
<!-- prettier-ignore-end -->
