Search code examples
pythonmacossketch-3

How to parse .sketch files in Python


How can I parse .sketch files generated by sketch - mac application?

I know that psd_tools can be used to parse .psd files generated in Adobe Photoshop.


Solution

  • I don't have any experience with Sketch, but I downloaded a sample .sketch file and it turned out to be an "SQLite 3.x database". This means you can open it with python's sqlite3 module.

    As it happens I had some code lying around that I wrote to inspect another sqlite database, so I took a look: It contains a metadata table and a "payload" table (called metadata and payload, respectively), both of which have just name and value columns. However, the payload table has just one row, and in both tables the values seem to be containers in some other format I don't recognize. So although sqlite3 is the file format, it appears that it is just the outer layer of the onion.