Use Git with Retool to version-control your app definitions. The Retool CLI exports apps as JSON files that can be committed to Git repositories, enabling branch-based development workflows, code review for UI changes, and environment promotion from development to staging to production. Git sync keeps your Retool apps under the same version control discipline as the rest of your codebase.
| Fact | Value |
|---|---|
| Tool | Git |
| Category | DevOps |
| Method | Development Workflow |
| Difficulty | Beginner |
| Time required | 30 minutes |
| Last updated | April 2026 |
Version Control Your Retool Apps with Git
Retool apps are often critical business infrastructure — a broken admin panel or data pipeline can impact operations teams immediately. Without version control, there's no easy way to roll back a bad change, review UI modifications before they go live, or maintain separate development and production versions of the same app. Git provides all of these capabilities for Retool through the Retool CLI and Source Code Sync feature.
Retool stores app definitions internally as structured JSON files that describe every component, query, event handler, and transformer in the application. The Retool CLI can export these JSON files to your local filesystem where they can be committed to any Git repository. When you need to restore a previous version or deploy to a new environment, the CLI imports the JSON back into Retool. This approach works with any Git hosting service — GitHub, GitLab, Bitbucket, or a self-hosted Git server.
For teams on Retool Business or Enterprise plans, Source Code Sync automates this process: Retool directly integrates with your Git provider and automatically commits app changes to your repository on every save, and imports from Git when you check out a different branch. This eliminates manual CLI export/import and enables proper code review workflows where UI changes go through pull requests just like application code does.
Integration method
Git integrates with Retool through the Retool CLI, which exports and imports Retool app definitions as JSON files. These files can be committed to any Git repository, enabling the same branching, PR review, and environment promotion workflows teams use for application code. Retool's built-in Source Code Sync feature (Business and Enterprise plans) automates this by directly connecting Retool to a GitHub, GitLab, or Bitbucket repository.
Prerequisites
- A Retool account with admin access to export app definitions
- Node.js installed on your local machine (required for the Retool CLI)
- A Git repository (GitHub, GitLab, Bitbucket, or self-hosted) where you'll store Retool app JSON
- Git installed locally and basic familiarity with Git commands (clone, commit, push, pull, branch)
- For Source Code Sync: a Retool Business or Enterprise plan
Step-by-step guide
Install and authenticate the Retool CLI
The Retool CLI is a Node.js package that provides commands for managing Retool apps programmatically. Install it globally using npm: npm install -g @tryretool/retool-cli. Verify the installation by running retool --version to confirm it's working. Next, authenticate the CLI with your Retool instance. Run retool login --retoolHost https://your-company.retool.com (replace with your Retool Cloud or self-hosted URL). The CLI will open a browser window for you to sign in to Retool. After signing in, your session is stored locally in a credentials file, and the CLI can make authenticated API calls to your Retool instance. For CI/CD pipelines and automated scripts, use a Retool API token instead of interactive login. Generate a token in Retool by going to Settings → Account → API Tokens → Create Token. Set the RETOOL_ACCESS_TOKEN environment variable to this token, and the CLI will use it automatically without requiring interactive login. Run retool whoami to confirm you're authenticated correctly — this command displays your Retool username and the connected Retool instance URL.
1# Install the Retool CLI2npm install -g @tryretool/retool-cli34# Authenticate with your Retool instance5retool login --retoolHost https://your-company.retool.com67# Verify authentication8retool whoami910# For CI/CD: use environment variable authentication11export RETOOL_ACCESS_TOKEN=your_api_token12retool whoamiPro tip: If your Retool instance requires SSO, interactive login may not work for CI/CD. Always create a dedicated Retool API token for automated workflows and store it as a CI/CD secret.
Expected result: The Retool CLI is installed and authenticated. Running retool whoami shows your Retool username and instance URL. You're ready to export and import apps.
Export Retool apps to JSON files
With the CLI authenticated, export your Retool apps to JSON files that can be committed to Git. Create a directory structure in your Git repository for Retool apps — a common pattern is /retool/apps/ with subdirectories for different app categories or teams. To list all apps available in your Retool instance, run retool apps list. This shows all apps with their names and IDs. Choose which apps to version-control — start with production-critical apps before adding development or testing apps. Export a specific app with retool apps export --appName "Your App Name" --output ./retool/apps/. This creates a JSON file named after the app in the output directory. The JSON file contains the complete app definition: all components and their configurations, all queries with SQL and transformer code, event handlers, page structure, and app settings. For exporting all apps at once, iterate through the app list: retool apps list --output json | jq -r '.[].name' | while read name; do retool apps export --appName "$name" --output ./retool/apps/; done. Add this command to a shell script in your repository for easy re-running. Commit the exported JSON files to Git: git add retool/apps/ && git commit -m 'Export Retool apps for version control'. Push to your remote repository to share with the team.
1# Export a specific app2retool apps export --appName "Customer Support Panel" --output ./retool/apps/34# Export all apps5retool apps list --output json | python3 -c "6import json, sys, subprocess7apps = json.load(sys.stdin)8for app in apps:9 subprocess.run(['retool', 'apps', 'export', '--appName', app['name'], '--output', './retool/apps/'])10"1112# Commit to Git13git add retool/apps/14git commit -m 'Export Retool apps - $(date +%Y-%m-%d)'15git push origin mainPro tip: Retool app JSON files can be large for complex apps with many queries. Add *.json files in retool/ to your .gitattributes with the linguist-generated attribute to prevent GitHub from treating them as code in language statistics.
Expected result: Retool app JSON files are exported to your Git repository and committed. Viewing the files shows the complete app definition including all components, queries, and transformers.
Implement branch-based development workflow
Establish a Git branching strategy for Retool app development. The recommended pattern follows the same conventions as application code development: Main branch: Always represents the production-ready state. No direct commits — changes come only through pull requests. When the main branch is updated, import the JSON into your production Retool environment. Staging branch: Merged from main + pending features. Used to deploy to your staging Retool environment for final verification before production. Feature branches: Each developer creates a branch for their Retool changes (e.g., feature/add-refund-button, fix/broken-customer-query). Export the modified app to JSON, commit to the feature branch, and open a pull request. To make a change: (1) Create a feature branch in Git. (2) Make the change in your Retool development environment. (3) Export the updated app JSON. (4) Commit the JSON to the feature branch. (5) Open a pull request for code review. (6) After approval, merge to staging/main and import the JSON to the corresponding Retool environment. Use git diff on the Retool JSON files to review exactly what changed between versions. The diffs show modified queries, added/removed components, and updated transformer logic — giving reviewers a clear picture of the change.
1# Create a feature branch for Retool changes2git checkout -b feature/add-bulk-refund-button34# Make changes in your Retool development environment, then export5retool apps export --appName "Order Management" --output ./retool/apps/67# Review what changed8git diff retool/apps/Order\ Management.json910# Commit the changes11git add retool/apps/12git commit -m 'Add bulk refund button to Order Management app'13git push origin feature/add-bulk-refund-button14# Open pull request on GitHub/GitLabPro tip: Add a Git pre-commit hook that runs retool apps validate on the JSON files before committing — this catches structural issues in the app definition before they reach code review.
Expected result: Your team has an established Git branching workflow for Retool apps. Changes go through feature branches and pull requests before being deployed to staging and production Retool environments.
Import Retool app JSON from Git to Retool environments
After merging a pull request or during a deployment process, import the updated JSON files back into the target Retool environment. This is the 'deploy' step of the Retool version control workflow. To import a single app from a JSON file, use: retool apps import --path ./retool/apps/app-name.json. If the app already exists in Retool with the same name, the CLI updates it. If it doesn't exist, the CLI creates it. For deploying to a different environment (e.g., from staging to production), switch the CLI authentication to the target environment first: set the RETOOL_HOST and RETOOL_ACCESS_TOKEN environment variables to the production Retool instance, then run the import commands. This pattern enables environment-specific deployments from the same Git repository. For automated CI/CD pipelines (GitHub Actions, CircleCI, Jenkins), add a deployment job that triggers on merges to specific branches. The job authenticates to the appropriate Retool environment and imports all changed JSON files. Use git diff --name-only to identify only the files that changed in the merge and import those specifically rather than re-importing every app. Retool's configuration variables (Settings → Configuration Variables) handle environment-specific values like API endpoints and database connections — the same app JSON works across environments because the variable names stay constant while only their values change per environment.
1#!/bin/bash2# CI/CD deployment script: deploy changed Retool apps to target environment3# Usage: ./deploy_retool.sh production45ENVIRONMENT=$167if [ "$ENVIRONMENT" = "production" ]; then8 export RETOOL_HOST="https://prod.retool.yourcompany.com"9 export RETOOL_ACCESS_TOKEN="$RETOOL_PROD_TOKEN"10elif [ "$ENVIRONMENT" = "staging" ]; then11 export RETOOL_HOST="https://staging.retool.yourcompany.com"12 export RETOOL_ACCESS_TOKEN="$RETOOL_STAGING_TOKEN"13fi1415# Find JSON files changed in the last merge16CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD -- 'retool/apps/*.json')1718# Import each changed file19for file in $CHANGED_FILES; do20 echo "Deploying $file to $ENVIRONMENT..."21 retool apps import --path "$file"22done2324echo "Deployment to $ENVIRONMENT complete."Pro tip: Before importing to production, always import to staging first and manually verify the app behaves correctly. Automated import without manual verification is safe for non-critical changes but risky for apps with production database write operations.
Expected result: Retool apps can be imported from Git JSON files into any Retool environment. Your CI/CD pipeline automatically deploys changed apps to the appropriate environment when branches are merged.
Configure Source Code Sync for automated Git integration
For Retool Business and Enterprise plans, Source Code Sync automates the export/import cycle by directly connecting Retool to your Git provider. Instead of manually running CLI commands, every app save in Retool automatically commits to your Git repository, and checking out a branch in your Git provider automatically loads the corresponding app version in Retool. To set up Source Code Sync, go to your Retool instance's Settings → Source Code Sync. Click 'Connect to GitHub' (or GitLab/Bitbucket). Authorize Retool to access your Git organization and select the repository where you want to store app definitions. Configure the branch mapping: specify which Git branch maps to which Retool environment. Typically, the main branch maps to production, a develop branch maps to staging, and feature branches map to development. Retool creates commits automatically with the message format '[Retool] App name - change description'. With Source Code Sync active, every developer working in Retool sees their changes immediately reflected in Git. Code reviewers can view diffs of Retool app changes in pull requests alongside application code changes. This is the most seamless Git workflow for Retool — it eliminates the manual CLI export step entirely. Note that Source Code Sync is bidirectional: changes in Git (e.g., from a merged PR) are synced back to Retool. Be careful about the sync direction — if someone edits the JSON directly in GitHub without going through Retool, those changes will appear in Retool on the next sync.
Pro tip: Source Code Sync works best when all team members use the same branching convention for both application code and Retool apps. Align your Retool branch mapping with your existing Git flow to avoid confusion about which Retool environment corresponds to which branch.
Expected result: Source Code Sync is active and automatically commits Retool app changes to your Git repository. Developers can track all Retool changes through Git history and review them in pull requests before deployment.
Common use cases
Branch-based development workflow for Retool apps
Establish a Git branching workflow where developers create feature branches for Retool app changes, export app JSON on the branch, push for code review, and merge to main after approval. Production Retool only gets updated after the PR is merged and the main branch JSON is imported — preventing untested changes from reaching production users.
Set up a Git repository for Retool apps with branches for dev, staging, and main. Use the Retool CLI to export apps to the dev branch during development, create PRs for review, and use a CI/CD pipeline to auto-import the approved changes into the staging and production Retool environments when branches are merged.
Copy this prompt to try it in Retool
Audit trail for Retool app changes
Maintain a complete history of all Retool app modifications with author, date, and change description recorded in Git commit messages. When an app behavior changes unexpectedly, compare Git diffs to see exactly which queries, components, or transformers were modified — giving your team a full audit trail for compliance and debugging.
Configure Git hooks that require descriptive commit messages for Retool JSON exports. Use git diff to compare app versions before deployment. Build a CI check that validates Retool JSON structure and flags unexpected changes to sensitive queries (database writes, API calls with destructive operations).
Copy this prompt to try it in Retool
Multi-environment Retool deployment pipeline
Maintain separate Retool environments (development, staging, production) with a Git-based promotion workflow. Feature branches deploy to development, main branch deploys to staging, and tagged releases deploy to production — with Retool's configuration variables handling environment-specific API keys and database connections automatically.
Set up three Retool organizations (dev, staging, prod) each with environment-specific Resources. Use Git branches to control which version is deployed where. Write a deployment script that exports from one environment's Retool, commits to the appropriate branch, and imports into the target environment.
Copy this prompt to try it in Retool
Troubleshooting
Retool CLI returns 'Authentication failed' when trying to export apps
Cause: The CLI session has expired, the Retool API token has been revoked, or the RETOOL_HOST environment variable points to the wrong instance URL.
Solution: Re-authenticate by running retool login --retoolHost https://your-company.retool.com, or set the RETOOL_ACCESS_TOKEN environment variable to a freshly generated API token from Retool Settings → Account → API Tokens. Verify the RETOOL_HOST value matches your exact Retool instance URL including the protocol (https).
Imported app JSON shows in Retool but queries fail with 'Resource not found' errors
Cause: The imported app references Resources (databases, APIs) by name, but the target Retool environment doesn't have Resources configured with those exact names.
Solution: Ensure all Resources referenced in the app are created in the target Retool environment with matching names. Resource names are case-sensitive and must match exactly — 'Production DB' and 'production db' are different resources. Use Retool's configuration variables with environment-specific values so the same Resource names work across environments with different credentials.
Git diffs of Retool app JSON are too large to review meaningfully
Cause: Retool app JSON files can be very large (100KB+) for complex apps, making git diff output overwhelming. Minor UI changes may appear to affect hundreds of lines.
Solution: Configure your Git repository to use a custom diff driver for JSON files that produces more readable output. Use tools like jq to pretty-print and normalize the JSON before diffing. For very large apps, consider splitting them into smaller, more focused apps to keep individual JSON files manageable.
1# Add to .gitattributes to use jq for JSON diff formatting2*.json diff=json34# Add to .gitconfig5[diff "json"]6 textconv = python3 -c "import json,sys; print(json.dumps(json.load(open(sys.argv[1])), indent=2))"Source Code Sync creates frequent commits with '[Retool] Auto-save' messages that clutter the Git history
Cause: Retool's auto-save feature commits on every change when Source Code Sync is active, resulting in many small commits that make the history noisy.
Solution: Configure Source Code Sync to use a separate branch for auto-saves rather than committing directly to your main development branch. Alternatively, squash commits when merging feature branches to clean up the history. Some teams keep Retool app changes in a separate repository specifically to isolate the auto-save commit noise from application code history.
Best practices
- Store Retool app JSON files in a dedicated directory (/retool/apps/) rather than mixing them with application code, and consider a separate Git repository for Retool apps if your main repo is already large
- Use meaningful commit messages that describe the business change rather than the technical change — 'Add bulk approval workflow to invoice panel' is more useful than 'Update table1 component config'
- Set up a CI check that validates Retool JSON structure on pull requests — detect structural issues before they reach production by running retool apps validate on changed JSON files
- Configure Retool's configuration variables with environment-specific values and use consistent variable names across all environments — this ensures the same app JSON deploys to dev, staging, and production without modification
- Back up Retool app JSON files to Git on a daily scheduled basis even if no changes are made — this ensures you always have a recent snapshot even if your team doesn't consistently use the CLI workflow
- Add .gitignore entries for any temporary Retool CLI cache files or authentication credential files that the CLI creates locally — these should not be committed to the repository
- For teams with many Retool apps, organize them in subdirectories by team or function (/retool/apps/engineering/, /retool/apps/finance/) to make the repository navigable
Alternatives
Choose GitLab if your team already uses GitLab for source control — Retool's Source Code Sync supports GitLab, and GitLab's built-in CI/CD pipelines can automate Retool app deployments on merge.
Choose VS Code as your editor for working with Retool app JSON files — VS Code provides JSON syntax highlighting, formatting, and diff viewing that makes reviewing Retool app changes more manageable.
Choose Docker if you're self-hosting Retool — Docker containers enable consistent Retool deployment environments and can be combined with Git-based configuration management for the full infrastructure-as-code stack.
Frequently asked questions
Does Retool have native Git support without using the CLI?
Yes, Retool's Source Code Sync feature (available on Business and Enterprise plans) provides native Git integration that automatically syncs app changes to your GitHub, GitLab, or Bitbucket repository without requiring the CLI. For Free and Team plans, the Retool CLI is the primary mechanism for version-controlling apps through Git.
Can I edit Retool app JSON files directly in a code editor instead of through Retool's visual builder?
Technically yes — the JSON files can be edited in any text editor and imported back into Retool. However, this approach is fragile: the JSON schema is complex and undocumented, minor structural errors cause import failures, and you lose the visual feedback that Retool's builder provides. Direct JSON editing is best used for minor text changes or bulk find-and-replace operations, not for building new UI structure.
How do I handle Retool apps that reference sensitive configuration like database passwords in the exported JSON?
Retool's exported app JSON does not include Resource credentials or configuration variable values — only the Resource names and configuration variable keys are stored in the JSON. This is by design: credentials stay in Retool's encrypted storage and never appear in the exported files. This makes Git-stored Retool app JSON safe to commit even to private repositories, as no actual secrets are included.
Can I use Git to roll back a Retool app to a previous version?
Yes. Check out the Git commit containing the previous version of the app JSON file, then run retool apps import --path ./retool/apps/your-app.json to restore that version in Retool. This is the primary rollback mechanism for Retool apps — find the last known-good commit in Git history and import it. Source Code Sync users can also use Retool's History panel which shows a timeline of app changes that can be directly reverted.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation