---
title: Import and export Databricks notebooks
description: Import and export Databricks notebooks in source, HTML, DBC, IPYNB, and RMarkdown formats, and convert script files to notebooks.
canonical_url: https://docs.databricks.com/aws/en/notebooks/notebook-export-import
---

# Import and export Databricks notebooks

Databricks can import and export notebooks in multiple formats, convert script files into notebooks, and export entire folders as a ZIP archive.

## Supported notebook formats

Databricks can import and export notebooks in the following formats:

* Source file: A file containing only source code statements with the extension `.scala`, `.py`, `.sql`, or `.r`.
* HTML: A Databricks notebook with the extension `.html`.
* Databricks `.dbc` archive.
* IPython notebook: A [Jupyter notebook](https://jupyter-notebook.readthedocs.io/en/stable/) with the extension `.ipynb`.
* RMarkdown: An [R Markdown document](https://rmarkdown.rstudio.com/) with the extension `.Rmd`.

## <a id="import-notebook" />Import a notebook

You can import an external notebook from a URL or a file. You can also import a ZIP archive of notebooks [exported in bulk](https://docs.databricks.com/aws/en/notebooks/notebook-export-import.md#export-all-notebooks-in-a-folder) from a Databricks workspace.

1. Click ![Notebook icon.](https://docs.databricks.com/aws/en/images/product-icons/NotebookIcon.svg) **Workspace** in the sidebar. Do one of the following:
   * Right-click on a folder and select **Import**.
   * To import a notebook at the top level of the current workspace folder, click the kebab menu at the upper right and select **Import**.
2. Specify the URL or browse to a file containing a supported external format or a ZIP archive of notebooks exported from a Databricks workspace.
3. Click **Import**.
   * If you choose a single notebook, it is exported in the current folder.
   * If you choose a DBC or ZIP archive, its folder structure is recreated in the current folder and each notebook is imported.

## <a id="convert" />Convert a file to a notebook

An asset in the workspace is identified as a notebook if it has an `.ipynb` extension, or contains the string `Databricks notebook source` in a comment in the first line and has one of the following extensions: `.py`, `.r`, `.scala`, `.sql`. Any write or rename of a notebook or file that changes these conditions, also changes the type of the notebook or file. For example, if you have a file `myfile.txt` that has `# Databricks notebook source` as the first line, renaming that file to `myfile.py` converts it into a notebook.

> [!NOTE]
>
> Converting between file and notebook types can have unexpected results, as notebooks have a specific IPYNB or source format. See [Notebook formats](https://docs.databricks.com/aws/en/notebooks/notebook-format.md#source-control-notebook-formats).

To convert Python, SQL, Scala, and R scripts to single-cell notebooks, add a comment to the first cell of the file:

### Python

```python
# Databricks notebook source
```

### SQL

```sql
-- Databricks notebook source
```

### Scala

```scala
// Databricks notebook source
```

### R

```r
# Databricks notebook source
```

To define cells in a script, use the special comment shown below. When you import the script to Databricks, cells are created as marked by the `COMMAND` lines shown.

### Python

```python
# COMMAND ----------
```

### SQL

```sql
-- COMMAND ----------
```

### Scala

```scala
// COMMAND ----------
```

### R

```r
# COMMAND ----------
```

<a id="export-notebook" />

## <a id="export-all-notebooks-in-a-folder" />Export notebooks

> [!NOTE]
>
> * When you export a notebook as HTML, IPython notebook (.ipynb), or archive (DBC), and you have not [cleared the command outputs](https://docs.databricks.com/aws/en/notebooks/notebook-outputs.md#clear), the outputs are included in the export.
> * For Python notebooks on serverless compute, you can include the base environment and dependencies in source file exports. See [Include the environment in source file exports](https://docs.databricks.com/aws/en/compute/serverless/dependencies.md#include-environment-source-file-exports).

To export a notebook:

1. With the notebook open, click **File** in the notebook toolbar, then click **Export...**.
2. Select the export file type from the dropdown menu.
3. If you selected IPython notebook, HTML, or DBC archive as the export file type, you can choose to include cell outputs or not by selecting or clearing **Include outputs**.
4. Click **Export**.

To export all notebooks in a workspace folder as a ZIP archive:

1. Click ![Notebook icon.](https://docs.databricks.com/aws/en/images/product-icons/NotebookIcon.svg) **Workspace** in the sidebar.
2. Right-click the folder and select **Download as**.
3. Select the download format:

   * **DBC Archive (notebooks only)**: Export a Databricks archive, a binary format that includes metadata and notebook command outputs.
   * **Zip - Source (notebook + files only)**: Export a ZIP archive of notebook source files, which can be imported into a Databricks workspace, used in a CI/CD pipeline, or viewed as source files in each notebook's default language. Notebook command outputs are not included.
   * **Zip - HTML (notebooks only)**: Export a ZIP archive of the notebooks in HTML format. Each notebook's HTML file can be imported into a Databricks workspace or viewed as HTML. Notebook command outputs are included.

   > [!NOTE]
   >
   > HTML Archive is not supported in AWS GovCloud workspaces.
