# Obsidian CLI

```yaml
permalink: cli
description: Anything you can do in Obsidian can be done from the command line.
```

Obsidian CLI is a command line interface that lets you control Obsidian from your terminal for scripting, automation, and integration with external tools.

Anything you can do in Obsidian you can do from the command line. Obsidian CLI even includes [developer commands](/content/help/cli#Developer%20commands/index.html) to access developer tools, inspect elements, take screenshots, reload plugins, and more.

Requires Obsidian 1.12 installer

Using the CLI requires the Obsidian 1.12 installer. See the [installer version update guide](/content/help/updates#Installer%20updates/index.html).

## Install Obsidian CLI

Upgrade to the latest [Obsidian installer version](/content/help/updates/index.html) (1.12.7+).

Enable Obsidian CLI in Obsidian:

1. Go to **Settings** → **General**.
2. Enable **Command line interface**.
3. Follow the prompt to register Obsidian CLI.

If you run into issues installing Obsidian CLI see [Troubleshooting](/content/help/cli#Troubleshooting/index.html).

## Get started

Obsidian CLI supports both single commands and a terminal user interface (TUI) with interactive help and autocomplete.

### Run a command

Run an individual command without opening the TUI:

```shell
# Run the help command
obsidian help
```

### Use the terminal interface

Use the TUI by entering `obsidian`. Subsequent commands can be entered without `obsidian`.

```shell
# Open the TUI, then run help
obsidian
help
```

The TUI supports autocomplete, command history, and reverse search. Use `Ctrl+R` to search your command history. See [Keyboard shortcuts](/content/help/cli#Keyboard%20shortcuts/index.html) for all available shortcuts.

## Examples

Here are a few examples of what Obsidian CLI can do.

### Everyday use

```shell
# Open today's daily note
obsidian daily

# Add a task to your daily note
obsidian daily:append content="- [ ] Buy groceries"

# Search your vault
obsidian search query="meeting notes"

# Read the active file
obsidian read

# List all tasks from your daily note
obsidian tasks daily

# Create a new note from a template
obsidian create name="Trip to Paris" template=Travel

# List all tags in your vault with counts
obsidian tags counts

# Compare two versions of a file
obsidian diff file=README from=1 to=3
```

### For developers

Many [Developer commands](/content/help/cli#Developer%20commands/index.html) are available for plugin and theme development. These commands allow agentic coding tools to automatically test and debug.

```shell
# Open developer tools
obsidian devtools

# Reload a community plugin you're developing
obsidian plugin:reload id=my-plugin

# Take a screenshot of the app
obsidian dev:screenshot path=screenshot.png

# Run JavaScript in the app console
obsidian eval code="app.vault.getFiles().length"
```

## How to

### Use parameters and flags

Commands can use **parameters** and **flags**. Most commands do not require any parameters or flags. Required parameters are marked as `required`. For example:

```shell
# Create a new note using the default "Untitled" name
obsidian create
```

A **parameter** takes a value, written as `parameter=value`. If the value has spaces, wrap it in quotes:

```shell
# Create a new note called "Note" with content "Hello world"
obsidian create name=Note content="Hello world"
```

A **flag** is a boolean switch with no value. Include it to turn it on, for example `open` and `overwrite` are flags:

```shell
# Create a note and open it
obsidian create name=Note content="Hello" open overwrite
```

For multiline content use `\n` for newline. Use `\t` for tab.

```bash
obsidian create name=Note content="# Title\n\nBody text"
```

### Target a vault

If your terminal's current working directory is a vault folder, that vault is used by default. Otherwise, the currently active vault is used.
Use `vault=<name>` or `vault=<id>` to target a specific vault. This must be the first parameter before your command:

```shell
obsidian vault=Notes daily
obsidian vault="My Vault" search query="test"
```

### Target a file

Many commands accept `file` and `path` parameters to target a specific file. If neither is provided, the command defaults to the active file.

- `file=<name>` resolves the file using the same link resolution as [wikilinks](/content/help/links/index.html), matching by file name without requiring the full path or extension.
- `path=<path>` requires the exact path from the vault root, e.g. `folder/note.md`.

```shell
# These are equivalent if "Recipe.md" is the only file with that name
obsidian read file=Recipe
obsidian read path="Templates/Recipe.md"
```

### Copy output

Add `--copy` to any command to copy the output to the clipboard:

```shell
read --copy
search query="TODO" --copy
```

## General commands

### `help`

Show list of all available commands.

| Parameter | Description |
| --- | --- |
| `<command>` | Show help for a specific command. |

### `version`

Show Obsidian version.

### `reload`

Reload the app window.

### `restart`

Restart the app.

## Bases

Commands for [Bases](/content/help/bases/index.html).

### `bases`

List all `.base` files in the vault.

### `base:views`

List views in the current base file.

### `base:create`

Create a new item in a base. Defaults to the active base view if no file is specified.

```bash
file=<name>        # base file name
path=<path>        # base file path
view=<name>        # view name
name=<name>        # new file name
content=<text>     # initial content

open               # open file after creating
newtab             # open in new tab
```

### `base:query`

Query a base and return results.

```bash
file=<name>                    # base file name
path=<path>                    # base file path
view=<name>                    # view name to query
format=json|csv|tsv|md|paths   # output format (default: json)
```

## Bookmarks

Commands for [Bookmarks](/content/help/plugins/bookmarks/index.html).

### `bookmarks`

List bookmarks.

```bash
# Total bookmark count
```

### `bookmark`

Add a bookmark.

```bash
file=<path>        # file to bookmark
subpath=<subpath>  # subpath (heading or block) within file
folder=<path>      # folder to bookmark
search=<query>     # search query to bookmark
url=<url>          # URL to bookmark
title=<title>      # bookmark title
```

## Command palette

Commands for [Command palette](/content/help/plugins/command-palette/index.html) and [Hotkeys](/content/help/hotkeys/index.html). This includes all commands registered by plugins.

### `commands`

List available command IDs.

```bash
filter=<prefix>    # filter by ID prefix
```

### `command`

Execute an Obsidian command.

```bash
id=<command-id>    # (required) command ID to execute
```

### `hotkeys`

List hotkeys for all commands.

```bash
total              # return hotkey count
verbose            # show if hotkey is custom
format=json|tsv|csv  # output format (default: tsv)
```

### `hotkey`

Get hotkey for a command.

```bash
id=<command-id>    # (required) command ID

verbose            # show if custom or default
```

## Daily notes

Commands for [Daily notes](/content/help/plugins/daily-notes/index.html).

### `daily`

Open daily note.

```bash
paneType=tab|split|window    # pane type to open in
```

### `daily:path`

Get daily note path. Returns the expected path even if the file hasn't been created yet.

### `daily:read`

Read daily note contents.

### `daily:append`

Append content to daily note.

```bash
content=<text>     # (required) content to append
paneType=tab|split|window    # pane type to open in

inline             # append without newline
open               # open file after adding
```

### `daily:prepend`

Prepend content to daily note.

```bash
content=<text>     # (required) content to prepend
paneType=tab|split|window    # pane type to open in

inline             # prepend without newline
open               # open file after adding
```

## File history

### `diff`

List or compare versions from local [File recovery](/content/help/plugins/file-recovery/index.html) and [Sync](/content/help/sync/index.html). Versions are numbered from newest to oldest.

```bash
file=<name>          # file name
path=<path>          # file path
from=<n>             # version number to diff from
to=<n>               # version number to diff to
filter=local|sync    # filter by version source
```

**Examples:**

```shell
# List all versions of the active file
diff

# List all versions of a specific file
diff file=Recipe

# Compare the latest version to the current file
diff file=Recipe from=1

# Compare two versions
diff file=Recipe from=2 to=1

# Only show Sync versions
diff filter=sync
```

### `history`

List versions from [File recovery](/content/help/plugins/file-recovery/index.html) only. See [sync:history](/content/help/cli#Sync/index.html) for the equivalent Sync command.

```bash
file=<name>        # file name
path=<path>        # file path
```

### `history:list`

List all files with local history.

### `history:read`

Read a local history version.

```bash
file=<name>        # file name
path=<path>        # file path
version=<n>        # version number (default: 1)
```

### `history:restore`

Restore a local history version.

```bash
file=<name>        # file name
path=<path>        # file path
version=<n>        # (required) version number
```

### `history:open`

Open file recovery.

```bash
file=<name>        # file name
path=<path>        # file path
```

## Files and folders

### `file`

Show file info (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
```

Example:

```
path       Notes/Recipe.md
name       Recipe
extension  md
size       1024
created    1700000000000
modified   1700001000000
```

### `files`

List files in the vault.

```bash
folder=<path>      # filter by folder
ext=<extension>    # filter by extension

total              # return file count
```

### `folder`

Show folder info.

```bash
path=<path>              # (required) folder path
info=files|folders|size  # return specific info only
```

### `folders`

List folders in the vault.

```bash
folder=<path>      # filter by parent folder

total              # return folder count
```

### `open`

Open a file.

```bash
file=<name>        # file name
path=<path>        # file path

newtab             # open in new tab
```

### `create`

Create or overwrite a file.

```bash
name=<name>        # file name
path=<path>        # file path
content=<text>     # initial content
template=<name>    # template to use

overwrite          # overwrite if file exists
open               # open file after creating
newtab             # open in new tab
```

### `read`

Read file contents (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
```

### `append`

Append content to a file (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
content=<text>     # (required) content to append

inline             # append without newline
```

### `prepend`

Prepend content after frontmatter (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
content=<text>     # (required) content to prepend

inline             # prepend without newline
```

### `move`

Move or rename a file (default: active file). This will automatically update [internal links](/content/help/links/index.html) if turned on in your [vault settings](/content/help/settings#Automatically%20update%20internal%20links/index.html).

```bash
file=<name>        # file name
path=<path>        # file path
to=<path>          # (required) destination folder or path
```

### `rename`

Rename a file (default: active file). The file extension is preserved automatically if omitted from the new name. Use [move](/content/help/cli#%60move%60/index.html) to rename and move a file at the same time. This will automatically update [internal links](/content/help/links/index.html) if turned on in your [vault settings](/content/help/settings#Automatically%20update%20internal%20links/index.html).

```bash
file=<name>        # file name
path=<path>        # file path
name=<name>        # (required) new file name
```

### `delete`

Delete a file (default: active file, trash by default).

```bash
file=<name>        # file name
path=<path>        # file path

permanent          # skip trash, delete permanently
```

## Links

Commands for [Backlinks](/content/help/plugins/backlinks/index.html) and [Outgoing links](/content/help/plugins/outgoing-links/index.html).

### `backlinks`

List backlinks to a file (default: active file).

```bash
file=<name>        # target file name
path=<path>        # target file path

counts             # include link counts
total              # return backlink count
format=json|tsv|csv  # output format (default: tsv)
```

### `links`

List outgoing links from a file (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path

total              # return link count
```

### `unresolved`

List unresolved links in vault.

```bash
total              # return unresolved link count
counts             # include link counts
verbose            # include source files
format=json|tsv|csv  # output format (default: tsv)
```

### `orphans`

List files with no incoming links.

```bash
total              # return orphan count
```

### `deadends`

List files with no outgoing links.

```bash
total              # return dead-end count
```

## Outline

Commands for [Outline](/content/help/plugins/outline/index.html).

### `outline`

Show headings for the current file.

```bash
file=<name>        # file name
path=<path>        # file path
format=tree|md|json  # output format (default: tree)

total              # return heading count
```

## Plugins

Commands for [Core plugins](/content/help/plugins/index.html) and [Community plugins](/content/help/community-plugins/index.html).

### `plugins`

List installed plugins.

```bash
filter=core|community  # filter by plugin type

versions               # include version numbers
format=json|tsv|csv    # output format (default: tsv)
```

### `plugins:enabled`

List enabled plugins.

```bash
filter=core|community  # filter by plugin type

versions               # include version numbers
format=json|tsv|csv    # output format (default: tsv)
```

### `plugins:restrict`

Toggle or check restricted mode.

```bash
on                 # enable restricted mode
off                # disable restricted mode
```

### `plugin`

Get plugin info.

```bash
id=<plugin-id>     # (required) plugin ID
```

### `plugin:enable`

Enable a plugin.

```bash
id=<id>                # (required) plugin ID
filter=core|community  # plugin type
```

### `plugin:disable`

Disable a plugin.

```bash
id=<id>                # (required) plugin ID
filter=core|community  # plugin type
```

### `plugin:install`

Install a community plugin.

```bash
id=<id>            # (required) plugin ID

enable             # enable after install
```

### `plugin:uninstall`

Uninstall a community plugin.

```bash
id=<id>            # (required) plugin ID
```

### `plugin:reload`

Reload a plugin (for developers).

```bash
id=<id>            # (required) plugin ID
```

## Properties

Commands related to [Properties](/content/help/properties/index.html).

### `aliases`

List aliases in the vault. Use `active` or `file`/`path` to show aliases for a specific file.

```bash
file=<name>        # file name
path=<path>        # file path

total              # return alias count
verbose            # include file paths
active             # show aliases for active file
```

### `properties`

List properties in the vault. Use `active` or `file`/`path` to show properties for a specific file.

```bash
file=<name>        # show properties for file
path=<path>        # show properties for path
name=<name>        # get specific property count
sort=count         # sort by count (default: name)
format=yaml|json|tsv  # output format (default: yaml)

total              # return property count
counts             # include occurrence counts
active             # show properties for active file
```

### `property:set`

Set a property on a file (default: active file).

```bash
name=<name>                                    # (required) property name
value=<value>                                  # (required) property value
type=text|list|number|checkbox|date|datetime   # property type
file=<name>                                    # file name
path=<path>                                    # file path
```

### `property:remove`

Remove a property from a file (default: active file).

```bash
name=<name>        # (required) property name
file=<name>        # file name
path=<path>        # file path
```

### `property:read`

Read a property value from a file (default: active file).

```bash
name=<name>        # (required) property name
file=<name>        # file name
path=<path>        # file path
```

## Publish

Commands for [Obsidian Publish](/content/help/publish/index.html).

### `publish:site`

Show publish site info (slug, URL).

### `publish:list`

List published files.

```bash

total              # return published file count
```

### `publish:status`

List publish changes.

```bash

total              # return change count
new                # show new files only
changed            # show changed files only
deleted            # show deleted files only
```

### `publish:add`

Publish a file or all changed files (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path

changed            # publish all changed files
```

### `publish:remove`

Unpublish a file (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
```

### `publish:open`

Open file on published site (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
```

## Random notes

Commands for [Random note](/content/help/plugins/random-note/index.html).

### `random`

Open a random note.

```bash
folder=<path>      # limit to folder

newtab             # open in new tab
```

### `random:read`

Read a random note (includes path).

```bash
folder=<path>      # limit to folder
```

## Search

Commands for [Search](/content/help/plugins/search/index.html).

### `search`

Search vault for text. Returns matching file paths.

```bash
query=<text>       # (required) search query
path=<folder>      # limit to folder
limit=<n>          # max files
format=text|json   # output format (default: text)

total              # return match count
case               # case sensitive
```

### `search:context`

Search with matching line context. Returns grep-style `path:line: text` output.

```bash
query=<text>       # (required) search query
path=<folder>      # limit to folder
limit=<n>          # max files
format=text|json   # output format (default: text)

case               # case sensitive
```

### `search:open`

Open search view.

```bash
query=<text>       # initial search query
```

## Sync

Commands for [Obsidian Sync](/content/help/sync/index.html).

Sync without the desktop app

These commands control Sync within the running Obsidian app. To sync vaults from the command line without the desktop app, see [Headless Sync](/content/help/sync/headless/index.html).

### `sync`

Pause or resume sync.

```bash
on                 # resume sync
off                # pause sync
```

### `sync:status`

Show sync status and usage.

### `sync:history`

List sync version history for a file (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path

total              # return version count
```

### `sync:read`

Read a sync version (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
version=<n>        # (required) version number
```

### `sync:restore`

Restore a sync version (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
version=<n>        # (required) version number
```

### `sync:open`

Open sync history (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path
```

### `sync:deleted`

List deleted files in sync.

```bash
total              # return deleted file count
```

## Tags

Commands for [Tags](/content/help/tags/index.html).

### `tags`

List tags in the vault. Use `active` or `file`/`path` to show tags for a specific file.

```bash
file=<name>        # file name
path=<path>        # file path
sort=count         # sort by count (default: name)

total              # return tag count
counts             # include tag counts
format=json|tsv|csv  # output format (default: tsv)
active             # show tags for active file
```

### `tag`

Get tag info.

```bash
name=<tag>         # (required) tag name

total              # return occurrence count
verbose            # include file list and count
```

## Tasks

Commands for task management.

### `tasks`

List tasks in the vault. Use `active` or `file`/`path` to show tasks for a specific file.

```bash
file=<name>        # filter by file name
path=<path>        # filter by file path
status="<char>"    # filter by status character

total              # return task count
done               # show completed tasks
todo               # show incomplete tasks
verbose            # group by file with line numbers
format=json|tsv|csv  # output format (default: text)
active             # show tasks for active file
daily              # show tasks from daily note
```

**Examples:**

```bash
# List all tasks in the vault
tasks

# List incomplete tasks in the vault
tasks todo

# List completed tasks from a specific file
tasks file=Recipe done

# List tasks from today's daily note
tasks daily

# Count tasks in daily note
tasks daily total

# List tasks with file paths and line numbers
tasks verbose

# Filter by custom status (quote special chars)
tasks 'status=?'
```

### `task`

Show or update a task.

```bash
ref=<path:line>    # task reference (path:line)
file=<name>        # file name
path=<path>        # file path
line=<n>           # line number
status="<char>"    # set status character

toggle             # toggle task status
daily              # daily note
done               # mark as done
todo               # mark as todo
```

**Examples:**

```bash
# Show task info
task file=Recipe line=8
task ref="Recipe.md:8"

# Toggle task completion
task ref="Recipe.md:8" toggle

# Toggle task in daily note
task daily line=3 toggle

# Set task status
task file=Recipe line=8 done      # → [x]
task file=Recipe line=8 todo      # → [ ]
task file=Recipe line=8 status=-  # → [-]
task daily line=3 done            # Mark daily note task as done
```

## Templates

Commands for [Templates](/content/help/plugins/templates/index.html).

### `templates`

List templates.

```bash

total              # return template count
```

### `template:read`

Read template content.

```bash
name=<template>    # (required) template name
title=<title>      # title for variable resolution

resolve            # resolve template variables
```

### `template:insert`

Insert template into active file.

```bash
name=<template>    # (required) template name
```

**Notes:**
- `resolve` option processes `{{date}}`, `{{time}}`, `{{title}}` variables
- Use `create path=<path> template=<name>` to create a file with a template

## Themes and snippets

Commands for [Themes](/content/help/themes/index.html) and [CSS snippets](/content/help/snippets/index.html).

### `themes`

List installed themes.

```bash
versions           # include version numbers
```

### `theme`

Show active theme or get info.

```bash
name=<name>        # theme name for details
```

### `theme:set`

Set active theme.

```bash
name=<name>        # (required) theme name (empty for default)
```

### `theme:install`

Install a community theme.

```bash
name=<name>        # (required) theme name

enable             # activate after install
```

### `theme:uninstall`

Uninstall a theme.

```bash
name=<name>        # (required) theme name
```

### `snippets`

List installed CSS snippets.

### `snippets:enabled`

List enabled CSS snippets.

### `snippet:enable`

Enable a CSS snippet.

```bash
name=<name>        # (required) snippet name
```

### `snippet:disable`

Disable a CSS snippet.

```bash
name=<name>        # (required) snippet name
```

## Unique notes

Commands for [Unique note creator](/content/help/plugins/unique-note/index.html).

### `unique`

Create unique note.

```bash
name=<text>        # note name
content=<text>     # initial content
paneType=tab|split|window    # pane type to open in

open               # open file after creating
```

## Vault

### `vault`

Show vault info.

```bash
info=name|path|files|folders|size  # return specific info only
```

### `vaults`

List known vaults.

```bash

total              # return vault count
verbose            # include vault paths
```

### `vault:open`

Switch to a different vault (TUI only).

```bash
name=<name>        # (required) vault name
```

## Web viewer

Commands for [Web viewer](/content/help/plugins/web-viewer/index.html).

### `web`

Open URL in web viewer.

```bash
url=<url>          # (required) URL to open

newtab             # open in new tab
```

## Wordcount

Commands for [Word count](/content/help/plugins/word-count/index.html).

### `wordcount`

Count words and characters (default: active file).

```bash
file=<name>        # file name
path=<path>        # file path

words              # return word count only
characters         # return character count only
```

## Workspace

Commands for [Workspace](/content/help/workspace/index.html) and the [Workspaces](/content/help/plugins/workspaces/index.html) plugin.

### `workspace`

Show workspace tree.

```bash
ids                # include workspace item IDs
```

### `workspaces`

List saved workspaces.

```bash

total              # return workspace count
```

### `workspace:save`

Save current layout as workspace.

```bash
name=<name>        # workspace name
```

### `workspace:load`

Load a saved workspace.

```bash
name=<name>        # (required) workspace name
```

### `workspace:delete`

Delete a saved workspace.

```bash
name=<name>        # (required) workspace name
```

### `tabs`

List open tabs.

```bash
ids                # include tab IDs
```

### `tab:open`

Open a new tab.

```bash
group=<id>         # tab group ID
file=<path>        # file to open
view=<type>        # view type to open
```

### `recents`

List recently opened files.

```bash

total              # return recent file count
```

## Developer commands

Commands to help you develop [Community plugins](/content/help/community-plugins/index.html) and [Themes](/content/help/themes/index.html). Learn more by heading to the [Obsidian Developer Documentation](https://docs.obsidian.md/).

### `devtools`

Toggle Electron dev tools.

### `dev:debug`

Attach/detach Chrome DevTools Protocol debugger.

```bash
on                 # attach debugger
off                # detach debugger
```

### `dev:cdp`

Run a Chrome DevTools Protocol command.

```bash
method=<CDP.method>  # (required) CDP method to call
params=<json>        # method parameters as JSON
```

### `dev:errors`

Show captured JavaScript errors.

```bash
clear              # clear the error buffer
```

### `dev:screenshot`

Take a screenshot (returns base64 PNG).

```bash
path=<filename>    # output file path
```

### `dev:console`

Show captured console messages.

```bash
limit=<n>                        # max messages to show (default 50)
level=log|warn|error|info|debug  # filter by log level

clear                            # clear the console buffer
```

### `dev:css`

Inspect CSS with source locations.

```bash
selector=<css>     # (required) CSS selector
prop=<name>        # filter by property name
```

### `dev:dom`

Query DOM elements.

```bash
selector=<css>     # (required) CSS selector
attr=<name>        # get attribute value
css=<prop>         # get CSS property value

total              # return element count
text               # return text content
inner              # return innerHTML instead of outerHTML
all                # return all matches instead of first
```

### `dev:mobile`

Toggle mobile emulation.

```bash
on                 # enable mobile emulation
off                # disable mobile emulation
```

### `eval`

Execute JavaScript and return result.

```bash
code=<javascript>  # (required) JavaScript code to execute
```
