Is it possible to format the .ase to a .txt for tilemaps?

So in Aseprite, when using the tilemap mode and holding Command (I’m on a Mac), it brings up the tile number over each tile.

I want to be able to export it to a text file in the same layout with the numbers and each tile saved individually.
… etc
then ‘3’ be like ‘water.png’, ‘1’ be ‘dirt.png’, and ‘2’ be ‘grass.png’

This may be silly, but I only ask because Pyxel does the text file thing and I’m following a SDL tutorial that uses that. I understand this likely isn’t super practical or anything, I just don’t want to purchase Pyxel and want to know if I don’t have to create a text file manually… Thank you!

Hi @MillyP1,

I don’t know what SDL is or if you have background in coding, but Aseprite supports scripting plugins with Lua, so that would allow you to customize your export.

The scripting reference is here. Not all tile map features are documented, so for more advanced work, you have to look at Aseprite’s source code. The docs for Lua are here in case you want to learn more about file i/o.

Below is a simplified example of how you could export a tile map image to a .txt file.

local filepath = "replace_this_with_your_path"

local activeSprite = app.activeSprite
if not activeSprite then return end

local activeImage = app.activeImage
if not activeImage then return end

-- Color mode is 4 when image is a tile map
-- in case you want to verify.
-- local colorMode = activeImage.colorMode

local rowStrings = {}
local imgWidth = activeImage.width
local imgHeight = activeImage.height

for y = 0, imgHeight - 1, 1 do
    local rowSample = Rectangle(0, y, imgWidth, 1)
    local pixelIterator = activeImage:pixels(rowSample)
    local rowPixels = {}
    for pixel in pixelIterator do
        local index = pixel()
        local x = pixel.x
        rowPixels[1 + x] = string.format("%d", index)

    local rowString = table.concat(rowPixels, ",")
    rowStrings[1 + y] = rowString

local totalString = table.concat(rowStrings, "\n")
local file, err =, "w")
if file then

if err then
    app.alert { title = "Error", text = err }

The file path string should be replaced. You might have to change the line ending from \n to whatever works for your setup.


1 Like
--  Script for Aseprite to export a Tilemap to a 2D-Array of Tileset-Numbers
--  Please don't hate on me that was the first lua-Script I have ever written in my whole life I really hate interpreter languages
--  License: Bro just use it 
if TilesetMode == nil then return app.alert "Use Aseprite 1.3" end
local spr = app.activeSprite
if not spr then return end
local d = Dialog("Export Tilemap as .txt File")
d:label{id="lab1",label="",text="Export Tilemap as .txt File for your own GameEngine"}
 :file{id = "path", label="Export Path", filename="",open=false,filetypes={"txt"}, save=true, focus=true}
 :number{id="vbegin",label="Index of first Tileset (Default 1): ", text="1",focus=true}
 :number{id="Size",label="Tiles per Row (Layer-Width / Tile-Width): ",text="16"}
 :label{id="lab2", label="",text="In the last row of the tilemap-layer there has to be at least one Tile \"colored\" to fully export the whole Tilemap"}
 :button{text="&Cancel" }
local data =
if not data.ok then return end
    local lay = app.activeLayer
    if(#data.path<=0)then app.alert("No path selected") end
    if not lay.isTilemap then return app.alert("Layer is not tilemap") end
    pc = app.pixelColor
    mapFile =,"w")
  for _,c in ipairs(lay.cels) do
    local img = c.image
    local i = 0
    for p in img:pixels() do
      if(p ~= nil) then
        if(data.vbegin==1) then 
          if(i+1<=data.Size and #data.seperator > 0)then mapFile:write(data.seperator) end
          if(i+1<=data.Size and #data.seperator > 0)then mapFile:write(data.seperator) end
        if(i==data.Size) then 

Thank you for such a quick reply!
I ended up using a different solution from someone else following the same tutorial. I posted their script as a reply.

I’m novice/intermediate with C++ and have zero experience with Lua other than the minimal Lua scripting I used to set up Neovim.

Anyways, I appreciate the help anyways!