ANIPIXELS
Guide

How to use SVG and PNG game icons in Godot 4

Updated 1 Nov 2026. Tested in Godot 4.7.2. By Anipixels.

Pack for this guide: Crisp Icons (free sampler on itch.io). Also fits: Crisp Pixel Icons.

Short answer: Godot turns an SVG into an ordinary texture when it imports it, at the size set by SVG > Scale in the Import dock: a 64 x 64 SVG at scale 2.0 becomes a 128 px texture, so import at the largest size you will show. Display icons with a TextureRect (expand mode Ignore Size, stretch mode Keep Aspect Centered) or a Button's icon, capped by the icon_max_width theme constant. Cut atlases into AtlasTexture regions, tint white icons with self_modulate or the button's icon_*_color theme colours, replace built-in icons with Theme.set_icon(), and draw pixel icons at whole-number scales with Nearest filtering.

1. Import SVG icons at the right size

Select the SVG files in the FileSystem dock, change SVG > Scale in the Import dock and click Reimport. The scale multiplies the SVG's own size, so for the 64 x 64 Crisp Icons SVGs:

  • scale 0.5 gives a 32 px texture (theme icons, small buttons);
  • scale 1.0 gives 64 px;
  • scale 2.0 gives 128 px (large reward icons, high-resolution screens).

After import the icon is a bitmap like any PNG: scaling it up in the game makes it soft, while scaling it down stays clean. Import at the largest size you display. One-colour white SVGs are the most flexible, because you can tint them any colour (step 4).

2. Pick PNG import settings

  • Compress > Mode: Lossless (the default for 2D) keeps icon edges exact. VRAM compression is for large 3D textures and can leave blocky marks on small icons.
  • Mipmaps > Generate: turn it on for icons drawn much smaller than their file (a 256 px icon shown at 48 px) and set the node's Texture > Filter to Linear Mipmap; leave it off for icons shown near their own size.
  • Process > Fix Alpha Border is on by default and stops dark fringes appearing around the transparent edges when an icon is scaled.
  • Pixel-art icons need Nearest filtering instead (step 7).

3. Draw SVGs at any size while the game runs

svg_icon.gd

class_name SvgIcon
## Draws an SVG into a texture at any pixel size while the game runs, for icons
## whose size you only know at runtime (a UI scale setting, a big reward pop-up).
## The SVG has to ship as a plain file: in the Import dock, set its import mode
## to "Keep File (exported as is)".

static func texture(path: String, px: int, view_box := 64.0) -> ImageTexture:
	var img := Image.new()
	if img.load_svg_from_string(FileAccess.get_file_as_string(path), px / view_box) != OK:
		push_error("Could not read " + path)
		return null
	return ImageTexture.create_from_image(img)

Use it when the size is only known while the game runs, such as a UI scale setting, and keep the result instead of rendering the same icon every frame. An imported SVG is replaced by its texture in an exported game, so this needs the SVG itself: set those files' Import As to Keep File (exported as is) in the Import dock.

4. Show icons in TextureRects and Buttons

icon_ui.gd

class_name IconUI
## Icons in TextureRects and Buttons, tinted per state.

## An icon drawn px tall (or as big as its box allows), keeping its shape.
static func icon_rect(tex: Texture2D, px: int) -> TextureRect:
	var r := TextureRect.new()
	r.texture = tex
	r.expand_mode = TextureRect.EXPAND_IGNORE_SIZE          # the box sets the size, not the texture
	r.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
	r.custom_minimum_size = Vector2(px, px)
	return r


## A button with the icon left of the text. icon_max_width shrinks a big icon
## (64 px here) to px wide, keeping its shape.
static func icon_button(text: String, tex: Texture2D, px := 32) -> Button:
	var b := Button.new()
	b.text = text
	b.icon = tex
	b.add_theme_constant_override("icon_max_width", px)
	return b


## White icons take any colour. These multiply the icon in each button state.
static func icon_colours(b: Button) -> void:
	b.add_theme_color_override("icon_normal_color", Color("6d2f47"))
	b.add_theme_color_override("icon_hover_color", Color("cc5c84"))
	b.add_theme_color_override("icon_pressed_color", Color.WHITE)
	b.add_theme_color_override("icon_disabled_color", Color(1, 1, 1, 0.35))
  • EXPAND_IGNORE_SIZE lets the box set the size instead of the texture, and STRETCH_KEEP_ASPECT_CENTERED draws the icon as large as fits without squashing it.
  • icon_max_width shrinks a 64 px icon to 24 px in the button, keeping its shape; the button grows by the icon plus its 4 px h_separation. icon_alignment and vertical_icon_alignment put the icon left, right, above or below the text.
  • The icon_*_color theme colours multiply the icon in each state, so a white icon takes the colour exactly. On a TextureRect, use self_modulate: modulate also tints the node's children.

5. Cut icons out of an atlas

icon_atlas.gd

class_name IconAtlas
extends RefCounted
## Cuts named icons out of one atlas image. The JSON gives each icon's rectangle,
## as in the Crisp Icons atlases: {"frames": {"coin": {"x": 0, "y": 0, "w": 64, "h": 64}, ...}}

var sheet: Texture2D
var frames: Dictionary
var _cache := {}


func _init(atlas: Texture2D, json_path: String) -> void:
	sheet = atlas
	frames = JSON.parse_string(FileAccess.get_file_as_string(json_path))["frames"]


func tex(icon: String) -> AtlasTexture:
	if not _cache.has(icon):
		var f: Dictionary = frames[icon]
		var t := AtlasTexture.new()
		t.atlas = sheet
		t.region = Rect2(f["x"], f["y"], f["w"], f["h"])
		t.filter_clip = true   # never pick up pixels of the icon next door
		_cache[icon] = t
	return _cache[icon]


## For plain grids, such as the Crisp Pixel Icons atlases (col and row are in its icons.json).
static func grid_cell(atlas: Texture2D, col: int, row: int, cell: int) -> AtlasTexture:
	var t := AtlasTexture.new()
	t.atlas = atlas
	t.region = Rect2(col * cell, row * cell, cell, cell)
	t.filter_clip = true
	return t
  • An atlas keeps hundreds of icons in one image file. Each AtlasTexture works anywhere a texture does: TextureRect, Button.icon, Sprite2D, theme icons.
  • filter_clip stops filtering from picking up pixels of the next cell, which matters when cells have no padding.
  • The JSON format above is the one in the Crisp Icons atlases (white, dark and badge at 64 and 128 px). The Crisp Pixel Icons atlases are plain grids, 24 columns wide, with each icon's col and row in icons.json; that pack's Godot project also has one ready-made AtlasTexture per icon.

6. Replace built-in icons with a Theme

icon_theme.gd

class_name IconTheme
## Replaces built-in control icons through a Theme. Theme icons are drawn at the
## texture's own size, so use 24 to 32 px textures here.

static func build(checked: Texture2D, unchecked: Texture2D, close: Texture2D) -> Theme:
	var t := Theme.new()
	t.set_icon("checked", "CheckBox", checked)
	t.set_icon("unchecked", "CheckBox", unchecked)
	t.set_icon("close", "Window", close)
	return t

Theme icons are drawn at the texture's own size, so a 64 px icon makes a huge check box: import the SVGs at scale 0.5 (32 px) for these. CheckBox also has radio_checked, radio_unchecked and _disabled versions of each; the full list of a control's theme icons is in the Theme editor and in the class reference. Dialogs such as AcceptDialog pick up the Window close icon.

7. Draw pixel icons at whole-number sizes

pixel_icon.gd

class_name PixelIcon
## A 16 px pixel-art icon drawn at a whole-number scale with no smoothing.

static func make(tex: Texture2D, scale: int) -> TextureRect:
	var r := TextureRect.new()
	r.texture = tex
	r.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
	r.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
	r.stretch_mode = TextureRect.STRETCH_SCALE
	r.custom_minimum_size = tex.get_size() * scale
	# containers must not stretch it to an in-between size
	r.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
	r.size_flags_vertical = Control.SIZE_SHRINK_CENTER
	return r
  • Show a 16 px icon at 32, 48 or 64 px (2x, 3x, 4x). At 24 px (1.5x) some art pixels become one screen pixel wide and others two, and the icon looks uneven.
  • Nearest filtering keeps the edges hard; set it on the node, or for the whole project in Rendering > Textures > Canvas Textures > Default Texture Filter.
  • The shrink-center size flags stop a container stretching the icon to an in-between size: in the test, a 3x icon stayed 48 px inside a 300 px wide VBoxContainer.
  • The 2x, 3x and 4x PNGs in a pixel icon pack are exact enlargements, so you can also use those directly. For a whole pixel-art game, scale the entire viewport instead: see the pixel-art RPG menu guide.

How this was tested

Run headless in Godot 4.7.2 with the Crisp Icons and Crisp Pixel Icons free sampler files, plus the atlases from the full packs to check the code against their JSON: SVGs imported at 32, 64 and 128 px from scales 0.5, 1.0 and 2.0, mipmaps were made only where turned on, a runtime SVG drew at 200 px, the atlas cell matched the single coin PNG, the grid cell for sword_gold came out at (32, 0), icon_max_width shrank a 64 px icon to 24 px, a 3x pixel icon stayed 48 px, and a CheckBox and an AcceptDialog used the theme icons.

Free assets to try

Crisp Icons Free: 42 rounded game icons from 13 categories (interface, arrows, media, game, economy, social and more) in white and dark, as 64 px PNG and as SVG with a 64 x 64 viewBox, in category folders with a manifest.json. Download Crisp Icons Free.

Crisp Pixel Icons Free: 42 pixel-art fantasy RPG icons at 16 x 16 as PNG 1x, 2x, 3x and 4x, with an icons.json. Download Crisp Pixel Icons Free.

The full Crisp Icons ($4.99) has 590 icons in white, dark and as coloured badges, PNG at 32 to 256 px, SVG, the atlases used in step 5 and a Godot 4 project with a CrispIcons.tex("coin") helper. Crisp Pixel Icons ($4.99) has 485 icons at 16 x 16 (361 designs and 124 variants), grid atlases with 16 to 64 px cells, a JSON and CSV index and Godot 4 AtlasTextures. About Crisp Pixel Icons: Claude (an AI assistant) designed everything in this pack: every icon is written out pixel by pixel as code. All 19 Crisp packs are also in the Crisp Everything Bundle for $17.99.

More guides

All guides