A practical import tool: Google Maps Timeline JSON โ Toggl Track time entries.
If you already use location history (for example office/coworking visits), this script helps you backfill working time into Toggl with less manual work.
You were at the office, you worked, but Toggl was not running. Instead of adding everything by hand, this script reads your Google Timeline export and creates Toggl entries for locations you define.
Goal: less tedious admin, cleaner time tracking.
- โ
Supports both Google export formats:
timelineObjects(legacy)semanticSegments(new)
- โ
Location matching via
place_id(preferred) or- coordinates + tolerance (fallback)
- โ Merges overlapping intervals (per same description)
- โ
Ignores short stays
< 10 minutes - โ Dry-run mode (preview only)
- โ Duplicate protection using overlap checks against existing Toggl entries
- โ Flexible configuration (CLI, config file, environment variables)
- Export your Google Timeline data as JSON.
- Define relevant locations in
locations.json. - The script filters matching visits.
- Intervals are cleaned/merged.
- Existing Toggl entries are checked for overlap.
- New non-overlapping entries are created in Toggl.
Google likes to move menu items around, but the path is usually one of these:
- Open Google Maps
- Tap your profile picture (top right)
- Your Timeline
- Tap the โฎ menu (top right) โ Settings and privacy
- Find Export Timeline data (sometimes nested under Location & privacy settings)
- Tap Export โ Save
You should get a JSON (sometimes a ZIP containing JSON). Save it to your phone and then copy it to your computer (USB / cloud / whatever) and point the script at that file.
On some Android builds the Timeline export is linked via system location services:
- Android Settings โ Location โ Location services โ Timeline โ Export Timeline data
- Go to https://takeout.google.com/
- Select Location History / Timeline
- Choose JSON export and download the archive
- Python 3.10+
- Toggl Track API token
- Toggl Workspace ID
- Google Timeline export (JSON)
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCreate local config files:
cp locations.example.json locations.json
cp config.example.json config.json
locations.jsonandconfig.jsonare gitignored and stay local.
Example:
[
{
"key": "office-main",
"description": "Office",
"place_id": "OPTIONAL_GOOGLE_PLACE_ID",
"coords": [48.137154, 11.576124],
"tolerance": 0.002
}
]Fields:
key: internal identifierdescription: Toggl entry descriptionplace_id: optional, preferred when availablecoords:[lat, lng]fallbacktolerance: matching tolerance in degrees (0.002โ ~200m)
--workspace-id--config-fileโtoggl_workspace_idTOGGL_WORKSPACE_ID(env)
--config-fileโtoggl_api_tokenTOGGL_API_TOKEN(env)
Example config.json:
{
"toggl_workspace_id": 1234567,
"toggl_api_token": "your_toggl_api_token"
}python maps_to_toggl.py ~/Timeline.json \
--dry-run \
--month 2026-02 \
--locations-file locations.json \
--workspace-id 1234567python maps_to_toggl.py ~/Timeline.json \
--month 2026-02 \
--locations-file locations.json \
--config-file config.jsonexport TOGGL_WORKSPACE_ID=1234567
export TOGGL_API_TOKEN=...
python maps_to_toggl.py ~/Timeline.json --month 2026-02 --locations-file locations.jsonpositional:
file Path to Google Timeline JSON
optional:
--dry-run Preview only, do not write to Toggl
--month YYYY-MM Import only one month
--year YYYY Import only one year
--locations-file PATH Locations file (default: locations.example.json)
--default-description Fallback description (default: Office)
--workspace-id INT Toggl workspace ID (highest priority)
--config-file PATH Optional JSON config file
- No hardcoded secrets in source code
- Local private files (
locations.json,config.json,.env) are gitignored locations.jsonmay contain sensitive location data- Never commit real API tokens to public repositories
- Duplicate detection is based on time overlap (not Toggl entry IDs)
- Very large imports can be slow due to Toggl rate limits
- Coordinate matching quality depends on GPS accuracy + chosen tolerance
Set token via one of these:
TOGGL_API_TOKENenvconfig.jsonwithtoggl_api_token
Set workspace ID via:
--workspace-id- or
config.jsontoggl_workspace_id - or env
TOGGL_WORKSPACE_ID
- Check
locations.json(coords/place_id) - Increase
toleranceif needed - Verify
--month/--yearfilters - Start with
--dry-run
- Run monthly with
--dry-run - Quickly verify output
- Run real import
- Add new places to
locations.jsonwhen needed
That keeps Toggl accurate without painful manual reconstruction.
Parts of this project were developed with assistance from generative AI tools. All generated code and text were reviewed and adapted by a human before publication.
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for details.