Use the strconv package's Itoa function.

For example:

package main

import (
    "strconv"
    "fmt"
)

func main() {
    t := strconv.Itoa(123)
    fmt.Println(t)
}
Answer from Klaus Byskov Pedersen on Stack Overflow
Discussions

go - Convert int32 to string in Golang - Stack Overflow
I need to convert an int32 to string in Golang. Is it possible to convert int32 to string in Golang without converting to int or int64 first? Itoa needs an int. FormatInt needs an int64. More on stackoverflow.com
🌐 stackoverflow.com
July 4, 2025
How do you convert an int to a string in Golang, and what’s the correct way to concatenate strings? - TestMu AI Community
Hello there!! I’m working with Go and have a couple of questions about fundamental type conversions and string manipulations. First, I’m trying to convert an int to a string, like this: i := 123 s := string(i)` However, instead of getting "123", I’m getting a strange character ('E'). ... More on community.testmuai.com
🌐 community.testmuai.com
0
June 27, 2025
Strings slices to Integer Slices the most optimal way
Do you need the most optimized solution? But anyway, a simple optimization is to allocate the slice up front instead of appending to it and growing it to the target length: integers := make([]int, len(lines)) for i, line := range lines { ... integers[i] = n ... More on reddit.com
🌐 r/golang
13
1
December 1, 2021
How to convert from rune to string?
asRunes := []rune("“") asString := string(asRunes) fmt.Println("As runes:", asRunes) fmt.Println("As string:", asString) Prints: As runes: [8220] As string: “ Where did you find 147? More on reddit.com
🌐 r/golang
8
7
June 26, 2024
Top answer
1 of 6
661

For example strconv.Atoi.

Code:

package main

import (
    "fmt"
    "strconv"
)

func main() {
    s := "123"

    // string to int
    i, err := strconv.Atoi(s)
    if err != nil {
        // ... handle error
        panic(err)
    }

    fmt.Println(s, i)
}
2 of 6
160

Converting Simple strings

The easiest way is to use the strconv.Atoi() function.

Note that there are many other ways. For example fmt.Sscan() and strconv.ParseInt() which give greater flexibility as you can specify the base and bitsize for example. Also as noted in the documentation of strconv.Atoi():

Atoi is equivalent to ParseInt(s, 10, 0), converted to type int.

Here's an example using the mentioned functions (try it on the Go Playground):

flag.Parse()
s := flag.Arg(0)

if i, err := strconv.Atoi(s); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

if i, err := strconv.ParseInt(s, 10, 64); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

var i int
if _, err := fmt.Sscan(s, &i); err == nil {
    fmt.Printf("i=%d, type: %T\n", i, i)
}

Output (if called with argument "123"):

i=123, type: int
i=123, type: int64
i=123, type: int

Parsing Custom strings

There is also a handy fmt.Sscanf() which gives even greater flexibility as with the format string you can specify the number format (like width, base etc.) along with additional extra characters in the input string.

This is great for parsing custom strings holding a number. For example if your input is provided in a form of "id:00123" where you have a prefix "id:" and the number is fixed 5 digits, padded with zeros if shorter, this is very easily parsable like this:

s := "id:00123"

var i int
if _, err := fmt.Sscanf(s, "id:%5d", &i); err == nil {
    fmt.Println(i) // Outputs 123
}
🌐
YourBasic
yourbasic.org › golang › convert-int-to-string
Convert between int, int64 and string · YourBasic Go
The fmt.Sprintf function is a useful general tool for converting data to string: s := fmt.Sprintf("%+8d", 97) // s == " +97" (width 8, right justify, always show sign) See this fmt cheat sheet for more about formatting integers and other types of data with the fmt package. Package strconv · golang.org ·
🌐
Golang.cafe
golang.cafe › blog › golang-int-to-string-conversion-example
Golang Int To String Conversion Example | Golang.cafe
April 27, 2022 - Let’s see an example on how we can use these functions to convert an integer to an ASCII string · package main import ( "fmt" "strconv" ) func main() { i := 10 s1 := strconv.FormatInt(int64(i), 10) s2 := strconv.Itoa(i) fmt.Printf("%v, %v\n", s1, s2) } As you can see the result is exactly the same. The expected output from the above snippet is as follows · 10, 10 · Looking to hire talented Golang engineers? Connect with top developers and scale your team faster ·
🌐
GitHub
gist.github.com › evalphobia › caee1602969a640a4530
golang benchmark: String and Int conversions · GitHub
Save evalphobia/caee1602969a640a4530 to your computer and use it in GitHub Desktop. Download ZIP · golang benchmark: String and Int conversions · Raw · atoi_test.go · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
ByteSizeGo
bytesizego.com › blog › convert-int-to-string-golang
How to convert an int to string in Golang
September 10, 2024 - strconv.Itoa(): Best for simple and efficient conversion of integers to strings without additional formatting.
Find elsewhere
🌐
Coding Rooms
codingrooms.com › blog › golang-int-to-string
GoLang Int to String
January 16, 2025 - The simplest way to convert an int to string in Go is to use the fmt.Sprint function.
🌐
ZetCode
zetcode.com › golang › inttostring
Converting Integers to Strings in Go
3 weeks ago - The Itoa is a convenience function which convers an integer to a string. ... The Itoa is equivalent to FormatInt(int64(i), 10).
🌐
Educative
educative.io › answers › how-to-convert-an-int-to-a-string-in-golang
How to convert an int to a string in Golang
An integer can be converted to a string in Golang using the Itoa function within the strconv library.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-convert-data-types-in-go
How To Convert Data Types in Go | DigitalOcean
April 28, 2025 - You can convert numbers to strings by using the strconv.Itoa method from the strconv package in the Go standard libary. If you pass either a number or a variable into the parentheses of the method, that numeric value will be converted into a string value.
🌐
Go Packages
pkg.go.dev › strconv
strconv package - strconv - Go Packages
FormatComplex converts the complex number c to a string of the form (a+bi) where a and b are the real and imaginary parts, formatted according to the format fmt and precision prec. The format fmt and precision prec have the same meaning as in FormatFloat. It rounds the result assuming that the original was obtained from a complex value of bitSize bits, which must be 64 for complex64 and 128 for complex128. func FormatFloat(f float64, fmt byte, prec, bitSize int) string
🌐
Sentry
sentry.io › sentry answers › go › converting an int to a string in go
Converting an Int to a String in Go | Sentry
October 15, 2024 - For example, the following function prints {, which is the Unicode code point value for {: ... The simplest and fastest way to convert integers to strings is to use the strconv.Itoa function (Itoa is short for “integer to ASCII”):
🌐
Leapcell
leapcell.io › blog › how-to-convert-between-int64-and-string-in-golang
How to Convert Between `int64` and `string` in Golang | Leapcell
May 9, 2019 - Efficiently convert between `int64` and `string` in Golang using `strconv` and `fmt.Sprintf`.
Top answer
1 of 5
119

One line answer is fmt.Sprint(i).

Anyway there are many conversions, even inside standard library function like fmt.Sprint(i), so you have some options (try The Go Playground):


1- You may write your conversion function (Fastest):

func String(n int32) string {
    buf := [11]byte{}
    pos := len(buf)
    i := int64(n)
    signed := i < 0
    if signed {
        i = -i
    }
    for {
        pos--
        buf[pos], i = '0'+byte(i%10), i/10
        if i == 0 {
            if signed {
                pos--
                buf[pos] = '-'
            }
            return string(buf[pos:])
        }
    }
}

2- You may use fmt.Sprint(i) (Slow)
See inside:

// Sprint formats using the default formats for its operands and returns the resulting string.
// Spaces are added between operands when neither is a string.
func Sprint(a ...interface{}) string {
    p := newPrinter()
    p.doPrint(a)
    s := string(p.buf)
    p.free()
    return s
}

3- You may use strconv.Itoa(int(i)) (Fast)
See inside:

// Itoa is shorthand for FormatInt(int64(i), 10).
func Itoa(i int) string {
    return FormatInt(int64(i), 10)
}

4- You may use strconv.FormatInt(int64(i), 10) (Faster)
See inside:

// FormatInt returns the string representation of i in the given base,
// for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z'
// for digit values >= 10.
func FormatInt(i int64, base int) string {
    _, s := formatBits(nil, uint64(i), base, i < 0, false)
    return s
}

Comparison & Benchmark (with 50000000 iterations):

s = String(i)                       takes:  5.5923198s
s = String2(i)                      takes:  5.5923199s
s = strconv.FormatInt(int64(i), 10) takes:  5.9133382s
s = strconv.Itoa(int(i))            takes:  5.9763418s
s = fmt.Sprint(i)                   takes: 13.5697761s

Code:

package main

import (
    "fmt"
    //"strconv"
    "time"
)

func main() {
    var s string
    i := int32(-2147483648)
    t := time.Now()
    for j := 0; j < 50000000; j++ {
        s = String(i) //5.5923198s
        //s = String2(i) //5.5923199s
        //s = strconv.FormatInt(int64(i), 10) // 5.9133382s
        //s = strconv.Itoa(int(i)) //5.9763418s
        //s = fmt.Sprint(i) // 13.5697761s
    }
    fmt.Println(time.Since(t))
    fmt.Println(s)
}

func String(n int32) string {
    buf := [11]byte{}
    pos := len(buf)
    i := int64(n)
    signed := i < 0
    if signed {
        i = -i
    }
    for {
        pos--
        buf[pos], i = '0'+byte(i%10), i/10
        if i == 0 {
            if signed {
                pos--
                buf[pos] = '-'
            }
            return string(buf[pos:])
        }
    }
}

func String2(n int32) string {
    buf := [11]byte{}
    pos := len(buf)
    i, q := int64(n), int64(0)
    signed := i < 0
    if signed {
        i = -i
    }
    for {
        pos--
        q = i / 10
        buf[pos], i = '0'+byte(i-10*q), q
        if i == 0 {
            if signed {
                pos--
                buf[pos] = '-'
            }
            return string(buf[pos:])
        }
    }
}
2 of 5
14

The Sprint function converts a given value to string.

package main

import (
     "fmt"
)

func main() {

      var sampleInt int32 = 1

      sampleString := fmt.Sprint(sampleInt)
      fmt.Printf("%+V %+V\n", sampleInt, sampleString)
}

// %!V(int32=+1) %!V(string=1)

See this example.

🌐
A Girl Among Geeks
agirlamonggeeks.com › home › how do you convert an int to a string in golang?
How Do You Convert an Int to a String in Golang?
November 27, 2024 - James Li (Go Developer Advocate, Cloud Native Computing Foundation). “When converting integers to strings in Golang, performance considerations are paramount in high-throughput applications. The strconv.Itoa function is optimized for speed and minimal memory allocation, making it ideal for ...
🌐
TestMu AI Community
community.testmuai.com › ask a question
How do you convert an int to a string in Golang, and what’s the correct way to concatenate strings? - TestMu AI Community
June 27, 2025 - Hello there!! I’m working with Go and have a couple of questions about fundamental type conversions and string manipulations. First, I’m trying to convert an int to a string, like this: i := 123 s := string(i)` Howev…
🌐
Medium
medium.com › @kode-n-rolla › type-conversion-in-go-a-handy-cheat-sheet-for-developers-51482d4dca0c
Type Conversion in Go: A Handy Cheat Sheet for Developers | by k0de-n-Яolla | Medium
July 12, 2025 - Let’s convert a string of digits ("12345") into integers using different methods. Method 1: Using strconv.ParseInt. Convert each rune to a string and then parse it as an integer:
🌐
Hyno
hyno.co › blog › converting-an-integer-to-a-string-in-golang-a-comprehensive-guide.html
How to Convert an Integer to a String in Golang
June 11, 2020 - The strconv package in Golang offers a convenient function called Itoa(). It converts an integer to its corresponding string representation.