---
schema_version: "1"
id: 7b07b80263b2c468dcfea62fc53cc1625af0967320079ef32269ba2d12af8208
title: project convert mdapi
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/project/cli_reference_project_convert_mdapi.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_project_convert_mdapi.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 80352a7f2419a4a561fca0042502bc1a49b4c41b6c10136d3ab8d822ebf6731b
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# project convert mdapi

Convert metadata retrieved via Metadata API into the source format used in Salesforce DX projects.

## Description for project convert mdapi

To use Salesforce CLI to work with components that you retrieved via Metadata API, first convert your files from the metadata format to the source format using this command.

To convert files from the source format back to the metadata format, run "sf project convert source".

To convert multiple metadata components, either set multiple --metadata &lt;name&gt; flags or a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --source-dir.

## Aliases for project convert mdapi

`force:mdapi:convert`

## 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;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;manifest</code> | <code>&#8209;x</code> | **Type:** Value<br><br>File path to manifest (package.xml) of metadata types to convert.<br><br>If you specify this flag, don’t specify --metadata or --source-dir. |
| <code>&#8209;&#8209;metadata</code> | <code>&#8209;m</code> | **Type:** Value<br><br>Metadata component names to convert. |
| <code>&#8209;&#8209;metadata&#8209;dir</code> | <code>&#8209;p</code> | **Type:** Value<br><br>Root of directory or zip file of metadata formatted files to convert.<br><br>The supplied paths can be to a single file (in which case the operation is applied to only one file) or to a folder (in which case the operation is applied to all metadata types in the directory and its sub-directories).<br><br>If you specify this flag, don’t specify --manifest or --metadata. If the comma-separated list you’re supplying contains spaces, enclose the entire comma-separated list in one set of double quotes. |
| <code>&#8209;&#8209;output&#8209;dir</code> | <code>&#8209;d</code> | **Type:** Value<br><br>Directory to store your files in after they’re converted to source format; can be an absolute or relative path. |
| <code>&#8209;&#8209;root&#8209;dir</code> | <code>&#8209;r</code> | **Type:** Value<br>**Required**<br><br>Root directory that contains the Metadata API–formatted metadata. |

## Examples for project convert mdapi

Convert metadata formatted files in the specified directory into source formatted files; writes converted files to your default package directory:

```shell
sf project convert mdapi --root-dir path/to/metadata
```

Similar to previous example, but writes converted files to the specified output directory:

```shell
sf project convert mdapi --root-dir path/to/metadata --output-dir path/to/outputdir
```
<!-- prettier-ignore-end -->
