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

# Import Snippets

> Import text files to Snippets AI by dragging and dropping them

## Overview

Snippets AI makes it effortless to import your existing snippet collections, code files, notes, or any text-based content. Simply drag and drop files from your computer directly into Snippets AI, and they're instantly converted into organized, searchable snippets.

This guide shows you how to import single files, bulk import entire directories, and migrate from other tools.

## Why Import Matters

You likely already have valuable content scattered across:

* Text files and Markdown notes
* Code snippet files (`.js`, `.py`, `.sql`, etc.)
* Documentation files
* Export files from other snippet managers
* Note-taking apps exports
* Gists and code samples

Import lets you consolidate everything into Snippets AI in minutes, not hours.

## How It Works

<iframe src="https://player.vimeo.com/video/1104087715?h=0&title=0&byline=0&portrait=0&autoplay=1&muted=1" width="100%" height="450" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen />

## Drag & Drop Import

### Single File Import

1. **Open Finder/Explorer**

   * Navigate to the file you want to import

2. **Select the File**

   * Click once to select

3. **Drag to Snippets AI**

   * Click and hold on the file
   * Drag it over to the Snippets AI window

4. **Drop Into Target Location**

   Drop onto:

   * **Specific Folder**: File imports into that folder
   * **Main Panel**: File imports into currently selected folder
   * **Empty Space**: File imports into root/current team

5. **Snippet Created**
   * New snippet appears with filename as title
   * File content becomes snippet content
   * Syntax automatically detected based on file extension

### Multiple Files Import

Import many files at once:

1. **Select Multiple Files**

   * In Finder/Explorer:
     * `Cmd/Ctrl + Click` for individual files
     * `Shift + Click` for range

2. **Drag Selection to Snippets AI**

   * All files drag together
   * Badge shows count (e.g., "12 files")

3. **Drop Into Target**

   * All files import into same destination folder

4. **Batch Processing**
   * Snippets AI processes files one by one
   * Progress indicator shows import status
   * All snippets appear when complete

### Folder Import

Import an entire directory:

1. **Drag a Folder** from Finder/Explorer
2. **Drop onto Snippets AI**
3. **Folder Structure Options:**

   **Option A: Flatten**

   * All files in folder import as snippets
   * No subfolder structure preserved
   * All snippets in target folder

   **Option B: Preserve Structure**

   * Each subfolder becomes a folder in Snippets AI
   * Nested structure maintained
   * Files become snippets in corresponding folders

Choose option in import dialog that appears.

## Supported File Types

### Code Files

All programming languages:

* `.js`, `.jsx` - JavaScript, React
* `.ts`, `.tsx` - TypeScript
* `.py` - Python
* `.rb` - Ruby
* `.go` - Go
* `.rs` - Rust
* `.java` - Java
* `.cpp`, `.c`, `.h` - C/C++
* `.cs` - C#
* `.swift` - Swift
* `.php` - PHP
* `.sql` - SQL
* `.sh`, `.bash`, `.zsh` - Shell scripts

**Syntax Auto-Detection:** Snippets AI automatically detects syntax from file extension.

### Markup & Documentation

* `.md` - Markdown
* `.mdx` - MDX
* `.txt` - Plain text
* `.html` - HTML
* `.css`, `.scss`, `.sass` - Stylesheets
* `.json` - JSON
* `.yaml`, `.yml` - YAML
* `.xml` - XML
* `.tex` - LaTeX

### Configuration Files

* `.env` - Environment variables
* `.config` - Config files
* `.toml` - TOML config
* `.ini` - INI files
* `Dockerfile` - Docker configs
* `.gitignore`, `.dockerignore` - Ignore files

### Other Formats

* `.log` - Log files (imported as text)
* `.csv` - CSV files (imported as text)
* No extension - Imported as plain text

### Unsupported File Types

Binary files are not supported:

* Images (`.png`, `.jpg`, `.gif`)
* Videos (`.mp4`, `.mov`)
* Archives (`.zip`, `.tar`)
* Executables (`.exe`, `.app`)

For media, use the [video/audio attachment features](/guides/video-audio-prompts) instead.

## Import Settings

### Snippet Naming

When importing, Snippets AI uses:

**Default:** Filename becomes snippet name

```
database-query.sql → Snippet name: "database-query"
```

**Custom:** You can rename during import

* Import dialog shows filename
* Edit name before confirming
* Applies to single file imports

**Batch Rename:** For multiple files

* Import with default names
* Bulk rename afterwards using folder actions

### Syntax Detection

Snippets AI auto-detects syntax:

| File Extension | Detected Syntax |
| -------------- | --------------- |
| `.js`, `.jsx`  | JavaScript      |
| `.ts`, `.tsx`  | TypeScript      |
| `.py`          | Python          |
| `.sql`         | SQL             |
| `.md`          | Markdown        |
| `.txt`         | Plain Text      |

**Manual Override:**

* After import, open snippet
* Change syntax via syntax selector
* See [Syntax Highlighting guide](/guides/syntax-highlighting)

### Tag Application

Apply tags during import:

**Method 1: Drop on Tag**

* Drag files to tag in sidebar
* Files import with that tag applied

**Method 2: Import Dialog**

* Some import dialogs allow tag selection
* Choose tags before confirming import

**Method 3: After Import**

* Import files first
* Select all imported snippets
* Drag to tags to apply

## Migration From Other Tools

### From TextExpander

1. **Export from TextExpander**

   * File → Export → Text File Format
   * Exports as `.txt` files

2. **Import to Snippets AI**

   * Drag exported files
   * Drop into Snippets AI
   * Snippets created from each file

3. **Reorganize**
   * Use folders/tags to organize
   * Set up shortcuts for text expansion

### From Raycast

1. **Locate Raycast Snippets**

   * Raycast stores snippets as JSON
   * Export via Raycast settings

2. **Convert to Text Files** (if needed)

   * Use script to extract snippets
   * Save each as `.txt` or `.md`

3. **Import to Snippets AI**
   * Drag files to Snippets AI
   * Apply tags for categorization

### From Notion

1. **Export Notion Pages**

   * Export as Markdown & CSV
   * Downloads `.md` files

2. **Import Markdown Files**

   * Drag `.md` files to Snippets AI
   * Preserves Markdown formatting

3. **Clean Up Imports**
   * Remove Notion metadata if present
   * Organize into folders

### From Alfred Snippets

1. **Export Alfred Snippets**

   * Alfred Preferences → Snippets → Export

2. **Import JSON or Text Files**

   * If plain text, drag to Snippets AI
   * If JSON, may need conversion script

3. **Set Up Shortcuts**
   * Configure keyboard shortcuts in Snippets AI

### From Gists

1. **Download Gists**

   * Clone gist repos or download files from GitHub

2. **Import to Snippets AI**

   * Drag gist files
   * Syntax auto-detected

3. **Tag by Language or Purpose**
   * Apply relevant tags
   * Organize by project

## Bulk Import Best Practices

<Tip>
  **Organize First**: Create folders in Snippets AI before importing. Drop files
  into appropriate folders during import.
</Tip>

<Tip>
  **Clean Filenames**: Rename files before importing if they have unclear names.
  Filename becomes snippet name.
</Tip>

<Tip>
  **Tag During Import**: Drop files on tags or apply tags immediately after
  import while they're fresh in mind.
</Tip>

<Tip>
  **Import in Batches**: Import related files together (e.g., all SQL queries),
  then organize, then import next batch.
</Tip>

<Tip>
  **Review After Import**: Quickly scan imported snippets to verify content
  imported correctly and syntax detected properly.
</Tip>

## Advanced Import

### CSV Import

Import structured data from CSV:

1. **Prepare CSV**

```csv theme={null}
name,content,tags,folder
Auth Function,const auth = () => {...},javascript auth,Functions
API Call,fetch('/api/data'),javascript api,Utils
```

2. **Import CSV**

   * Snippets AI can parse CSV with headers
   * Creates snippets with specified tags/folders

3. **Map Columns**
   * Import dialog maps CSV columns to snippet fields
   * Flexible column mapping

### JSON Import

Import from JSON exports:

```json theme={null}
[
	{
		"name": "React Component",
		"content": "const Component = () => {...}",
		"tags": ["react", "component"],
		"syntax": "javascript"
	}
]
```

Snippets AI can parse this format directly.

### API Import

For programmatic import, use the Snippets AI API:

```javascript theme={null}
const files = await fs.readdir('./snippets');

for (const file of files) {
	const content = await fs.readFile(`./snippets/${file}`, 'utf-8');

	await fetch('https://api.getsnippets.ai/v1/snippets', {
		method: 'POST',
		headers: {
			Authorization: 'Bearer YOUR_API_KEY',
			'Content-Type': 'application/json',
		},
		body: JSON.stringify({
			name: file.replace(/\.[^/.]+$/, ''), // Remove extension
			content: content,
			syntax: detectSyntax(file),
			folder_id: 'your-folder-id',
		}),
	});
}
```

See [API Reference](/api-reference/snippets/create-snippet) for details.

## Troubleshooting

### Import Failed

If files don't import:

1. **Check File Type**: Ensure file is text-based, not binary
2. **File Size**: Very large files (>10MB) may fail; split them up
3. **Permissions**: Ensure Snippets AI has file system access
4. **Encoding**: Files should be UTF-8 encoded

### Wrong Syntax Detected

If syntax highlighting is incorrect:

1. Open imported snippet
2. Click syntax selector
3. Choose correct syntax manually
4. Syntax is saved with snippet

### Duplicate Imports

If you accidentally import same files twice:

1. Use search to find duplicates
2. Select duplicate snippets
3. Delete them
4. Or use "Merge Duplicates" feature if available

## What's Next

<Card title="Drag & Drop Organization" icon="hand" href="/guides/drag-drop-snippets">
  Learn how to organize imported snippets with drag & drop
</Card>

<Card title="Syntax Highlighting" icon="palette" href="/guides/syntax-highlighting">
  Adjust syntax highlighting for imported code snippets
</Card>

<Card title="API Reference: Create Snippets" icon="code" href="/api-reference/snippets/create-snippets">
  Use the API for programmatic bulk import
</Card>
