Google Chrome (and Chromium) provides several command-line options for customizing how the browser runs. One of the most useful for developers, testers, and power users is --user-data-dir. This flag lets you control where Chrome stores its entire user profile, including settings, extensions, cookies, and browsing history.
By default, Chrome saves user data (profiles, preferences, browsing history, etc.) in a predefined location that depends on your operating system (for example, %LOCALAPPDATA%\Google\Chrome\User Data on Windows). When you specify --user-data-dir, Chrome will instead use the folder you provide as the root directory for all user data.
This makes it possible to run Chrome with isolated, temporary, or portable profiles without interfering with your main browser setup.
-
Testing and Debugging Run Chrome with a clean, disposable profile to avoid interference from your personal browsing history or extensions.
-
Automation Tools like Selenium, Puppeteer, or Playwright often rely on
--user-data-dirto launch Chrome with a controlled environment. -
Parallel Profiles Launch multiple independent Chrome instances, each with its own set of extensions and settings, by pointing them to different directories.
-
Portable Profiles Place a profile in a custom folder (e.g., on an external drive) so that you can carry specific settings and extensions across systems.
When you create a profile via --user-data-dir, Chrome initializes a full set of files and folders. Key components include:
Bookmarks— Your saved bookmarks.History— Browsing history database.Cookies— Website cookies.Extensions/— Installed Chrome extensions.Preferences— General browser configuration file.Login Data— Stored passwords (encrypted using the OS’s keyring or credential store).Local Storage/,IndexedDB/— Site-specific offline storage.
Essentially, everything that defines your browsing environment lives here, isolated from your main Chrome profile.
It’s important not to confuse --user-data-dir with --profile-directory:
-
--user-data-dirPoints to the root folder that contains one or more profiles. This determines the entire storage location for Chrome’s data. -
--profile-directorySelects a specific profile within the default (or specified) user data directory. For example, Chrome internally names profiles likeDefault,Profile 1,Profile 2, etc.
In short:
- Use
--user-data-dirto redirect Chrome to a completely different storage root. - Use
--profile-directoryto pick which sub-profile to load within that root.