How to Convert macOS Icon (.icns) to Image (.png)

A simple command line to convert .icns file to .png

Let’s say you want to write a blog post for a certain macOS app. You write it great, add screenshots here and there to make the tutorial easy to follow. It’s all done, until it’s time to publish. You probably need to make a cover image at the top of your post or for social media thumbnail. To make it relevant, you might need the icon of the app.

Every macOS app has an icon file inside of it. The filetype is Apple Icon Image format with .icns extension. But you can’t use it in your image editing software like Affinity Photo. You need to convert it to a Portable Network Graphics (PNG) first.

Apple already include a command line tool to do that. You can execute it by using following command on Terminal.

sips -s format png input.icns --out output.png

Example of .icns to .png Conversion

Let’s see the command in action. For this example, I use Automator.app icon.

First, open /Application/ in Finder. Find Automator.app, right click on it, and click Show Package Contents. You can find the Automator.icns from following path.

/Applications/Automator.app/Contents/Resources/Automator.icns

Copy the selected icon file to the Desktop.

Next, open the Terminal app. We need to change directory to Desktop.

cd ~/Desktop

After that, enter following command to convert Automator icon file into a PNG image.

$ icns-to-png Automator.icns Automator.png
/Users/junian/Desktop/Automator.icns
  /Users/junian/Desktop/Automator.png

And that’s it. You’ll find Automator.png file on the Desktop.

Make it simple

You can make the command more simple and easier to remember by writing a bash function. The following snippet is the bash function I use on my macOS.

function icns-to-png()
{
  sips -s format png $1 --out $2
}

With the previous bash function, I can easily enter the command like following snippet.

icns-to-png input.icns output.png

That’s all I can write today. Thanks for reading! Hope this tutorial is helpful for you.