Dataview for VS Code Markdown Preview
Bring Obsidian Dataview query power to VS Code's built-in Markdown preview.
Query your workspace's Markdown notes using DQL (Dataview Query Language) — with support for TABLE, LIST, TASK, and CALENDAR views, plus inline expressions and DataviewJS.
Features
- 🔍 Automatic indexing of all Markdown files with live-updating
- 📊 TABLE queries with custom columns, sorting,
GROUP BY, and FLATTEN
- 📋 LIST queries with optional extra fields
- ✅ TASK queries across all files, with due dates and emoji shorthands (🗓️ ✅ ⏳ 🛫)
- 📅 CALENDAR view for date-based data
- 🧮 Inline expressions —
`= this.file.name` renders current page metadata
- 🏷️ Inline fields —
[key:: value] and key:: value syntax, with visual rendering
- 🧩 DataviewJS support (optional, with trusted-path security control)
- 📦 60+ built-in functions — date, string, list, math, logic operations
- 🏷️ Full metadata support: YAML frontmatter, tags, wikilinks, implicit fields
- ⚡ Parallel indexing — 8x concurrent file processing for large workspaces
Usage
DQL Queries
Create a ```dataview code block in any Markdown file:
```dataview
TABLE file.ctime AS "Created", file.mtime AS "Modified"
FROM "notes"
WHERE file.size > 100
SORT file.mtime DESC
LIMIT 10
```
Query Types
| Type |
Description |
Example |
TABLE |
Tabular output with configurable columns |
TABLE field1, field2 AS "Label" FROM #tag |
LIST |
Bulleted list of files |
LIST FROM "projects" |
TASK |
Task list across files |
TASK FROM #todo |
CALENDAR |
Calendar view by date |
CALENDAR due FROM #project |
Pipeline Commands
TABLE column1, column2 AS "Name"
FROM #tag AND "folder"
WHERE condition
SORT field ASC
GROUP BY category
FLATTEN tags
LIMIT 20
FROM — filter by tag (#tag), folder ("path"), file, or link ([[page]])
WHERE — filter rows with boolean expressions
SORT — sort by one or more fields (ASC/DESC)
GROUP BY — group results with rows.field swizzling
FLATTEN — expand array fields into multiple rows
LIMIT — restrict result count
Inline Expressions
Use backtick-wrapped expressions in your prose:
Created: `= this.file.ctime`
Tags: `= this.file.tags`
Rating: `= this.rating`
Dataview indexes three sources of metadata:
- Implicit fields —
file.name, file.path, file.ctime, file.mtime, file.size, file.tags, file.inlinks, file.outlinks, file.tasks, and more
- YAML Frontmatter — All fields in
--- blocks are queryable with dot notation for nested objects
- Inline fields —
Key:: Value syntax within Markdown body
Available Functions
| Category |
Functions |
| Constructors |
date(), dur() |
| Type checking |
typeof(), isnumber(), isstring(), isdate(), islink(), etc. |
| Numeric |
round(), floor(), ceil(), min(), max(), sum(), average() |
| String |
lower(), upper(), contains(), length(), regexmatch(), replace(), split(), join(), trim() |
| List |
filter(), map(), flat(), extract(), sort(), reverse(), nonnull() |
| Date |
dateformat(), dateadd(), datestart(), dateend(), striptime() |
| Logic |
default(), choice() |
DataviewJS (Optional)
Enable DataviewJS in settings (dataview.enableJavascript: true), then use:
```dataviewjs
dv.table(["Name", "Created"], dv.pages("#project")
.sort(p => p.file.ctime, "desc")
.limit(10)
.map(p => [p.file.name, p.file.ctime]))
```
⚠️ Security Warning: DataviewJS runs arbitrary JavaScript from your notes in the Markdown preview. Only enable if you trust all content in your workspace.
Configuration
| Setting |
Default |
Description |
dataview.enableJavascript |
false |
Enable DataviewJS code blocks |
dataview.enableInlineQueries |
true |
Enable inline = expr expressions |
dataview.defaultDateFormat |
"yyyy-MM-dd" |
Default date format |
dataview.warnOnEmptyResult |
true |
Show warning for empty query results |
dataview.taskEmojis |
true |
Parse task emoji shorthands (🗓️, ✅, etc.) |
dataview.excludedFolders |
["node_modules", ".git", ".vscode"] |
Folders to exclude from indexing |
dataview.javascriptTrustedPaths |
[] |
Folder paths trusted for DataviewJS. Empty = trust all. |
Commands
- Dataview: Re-index workspace — Force a full reindex of all Markdown files
- Dataview: Show index statistics — Display page/tag/inlink counts
Requirements
Known Limitations
- DataviewJS is sandboxed in the preview webview and cannot access the filesystem or VS Code API
- TASK queries are read-only (checking a task in the preview does not modify the source file)
- Link dereferencing (
[[Page]].field) is limited to indexed pages
- Very large workspaces (10,000+ files) may experience slower indexing on startup
License
MIT
| |