Cloudflare D1 Studio
Cloudflare D1 Studio lets you browse and query remote D1 databases without leaving VS Code.
Project website · Source and releases
Features
- Dedicated D1 activity-bar explorer for databases, tables, views, indexes, and triggers.
- Table context action to display the first 1000 unordered rows.
- Executable D1 SQL notebooks with SQLite-aware syntax highlighting.
- Run a complete cell with VS Code's native notebook control, or select SQL and use Execute Selected SQL.
- Query results stay in the same notebook directly below their SQL cell. Multi-statement executions produce one ordered result section per Cloudflare result, including metadata for statements that return no rows. Navigate focused grid cells with the arrow, Home, and End keys.
- First-class support for read-only and editable API tokens.
- Copy the Account ID from the Cloudflare dashboard. It is shown on the account overview and in Workers & Pages.
- Create a scoped Cloudflare API token:
- Choose account permission D1 Read for browsing, table content, and
SELECT queries.
- Choose D1 Edit only if the extension must execute statements that alter data or schema.
- Restrict the token to the intended Cloudflare account.
- Open the Command Palette and run D1 Studio: Configure Credentials.
- Enter the account ID and token. The extension validates them by listing D1 databases; it never issues a test write.
The account ID is stored as the d1Studio.accountId VS Code user setting. The token is stored only in VS Code Secret Storage and is never written to settings or logs.
When a D1 Read token submits a mutating statement, Cloudflare rejects that statement and D1 Studio explains that D1 Edit is required. The explorer, credentials, open SQL, and subsequent read queries remain available.
Browse and query
- Expand a database to load its Tables, Views, Indexes, and Triggers groups. Index entries show their owning table; internal SQLite/D1 objects remain hidden.
- Right-click a table or view and choose View Content (First 1000 Rows). The generated query is an unordered
SELECT * ... LIMIT 1000; “latest” is not inferred because D1 tables do not share a universal timestamp column.
- Right-click any table, view, index, or trigger and choose View DDL to open its stored
CREATE statement in a new database-associated notebook, formatted as readable SQLite SQL with two-space indentation.
- Right-click a database and choose New Query.
- Run a complete SQL cell with its notebook play button. To run only part of a cell, select one or more complete SQL statements and choose Execute Selected SQL. Separate statements with semicolons or start each top-level command on a new line; the block is sent to Cloudflare in one request and its ordered results appear below the cell.
- Use the explorer refresh button after making changes outside the extension. Successful mutations executed in D1 Studio refresh the affected database automatically.
New query notebooks start as untitled documents. Save one with the .d1nb extension to retain its SQL and D1 database association; query outputs are intentionally not persisted.
Install a local VSIX
cd extension
npm ci
npm run package
code --install-extension cloudflare-d1-studio-0.2.1.vsix
Development
cd extension
npm run typecheck
npm test
npm run test:integration
npm run package
Integration tests download and launch a VS Code test instance. On headless Linux, run them through xvfb-run -a.
Troubleshooting
Run D1 Studio: Show Logs from the Command Palette, or click the Output icon in the D1 explorer title. The D1 Studio channel records extension activation, credential validation, Cloudflare request status and timing, notebook query execution, result rendering, and schema refreshes. Tokens, authorization headers, SQL values, and returned row contents are never logged.
Security and operational notes
- Cloudflare remains the authority for every operation; the extension does not try to bypass token scope.
- API traffic uses HTTPS and the official Cloudflare REST API.
- Results remain structured data until the isolated notebook renderer inserts values as text, preventing returned values from becoming executable HTML.
- Cloudflare describes the D1 REST API as an administrative interface subject to the global Cloudflare API rate limit. This extension is intended for interactive desktop administration, not application traffic.