Can you export Screen Time to CSV?

Updated

Not from Apple's Screen Time; it has no CSV or any other export. On a Mac you can make a CSV yourself by querying the system database knowledgeC.db with the built-in sqlite3 tool, after giving Terminal Full Disk Access. It only covers the last four weeks or so, and the numbers may not match Apple's report exactly. Without a Mac, the only route is typing numbers from screenshots into a spreadsheet.

Make a CSV from knowledgeC.db on a Mac

  1. Open Apple menu > System Settings > Privacy & Security > Full Disk Access, turn it on for Terminal (use the + button to add it if it isn't listed), then quit and reopen Terminal.
  2. Make a working folder: mkdir -p ~/Desktop/screentime-copy
  3. Copy the database and its companion files, so you never touch the live one: cp ~/Library/Application\ Support/Knowledge/knowledgeC.db* ~/Desktop/screentime-copy/
  4. Check that the copy opened: sqlite3 ~/Desktop/screentime-copy/knowledgeC.db ".tables" should list tables including ZOBJECT and ZSOURCE.
  5. Run the query below with CSV output, sending it to a file on your Desktop.
  6. Open screen-time.csv in Numbers or Excel.
  7. Turn Full Disk Access for Terminal back off if you don't need it anymore.

The query adds up app usage per day and per app. Timestamps in this database are Mac absolute time, seconds since January 1, 2001, so adding 978307200 turns them into normal Unix time:

sqlite3 -header -csv ~/Desktop/screentime-copy/knowledgeC.db "
SELECT
  date(o.ZSTARTDATE + 978307200, 'unixepoch', 'localtime') AS day,
  o.ZVALUESTRING AS app,
  ROUND(SUM(o.ZENDDATE - o.ZSTARTDATE) / 60.0, 1) AS minutes,
  s.ZDEVICEID AS device
FROM ZOBJECT o
LEFT JOIN ZSOURCE s ON o.ZSOURCE = s.Z_PK
WHERE o.ZSTREAMNAME = '/app/usage'
GROUP BY day, app, device
ORDER BY day, minutes DESC;
" > ~/Desktop/screen-time.csv

app is the bundle identifier, such as com.apple.Safari. device separates rows from different devices when other devices' data is present. Website time is in a separate stream, /app/webUsage, which you can query the same way.

Read the result carefully

More background on the file is in knowledgeC.db and Screen Time.

Without a Mac: screenshots and a manual log

On iPhone there's no file to query. Instead:

It's tedious for daily per-app data, but realistic for weekly totals. You can also turn on Share Across Devices so your iPhone's usage reaches a Mac, then use the method above. See exporting from iPhone.

Where Screen Time History helps

Screen Time History is a Mac app that reads the same Screen Time data with Full Disk Access, so you don't need Terminal or SQL. It keeps every day from the day you install it, including your iPhone when Share Across Devices is on, and exports daily per-app time for the whole history. It can't export days Apple removed before installation.

Other languages: العربية · Čeština · Deutsch · Deutsch (Schweiz) · Español · Filipino · Français · हिन्दी · Bahasa Indonesia · Italiano · 日本語 · 한국어 · Bahasa Melayu · Nederlands · Polski · Português (Brasil) · Română · Русский · Svenska · ไทย · Türkçe · Українська · Tiếng Việt · 简体中文 · 繁體中文


Screen Time History · Privacy · Not affiliated with Apple.