← All notes

Go strconv: convert values to and from strings

Answer: Package strconv implements conversions to and from string representations of basic data types. The most common numeric conversions are Atoi (string to int) and Itoa (int to string). ParseBool, ParseFloat, ParseInt, and ParseUint convert strings to values.

Examples

package main
import "strconv"

func main() {
    i, _ := strconv.Atoi("-42")
    s := strconv.Itoa(-42)
    _, _, _ = i, s, strconv.FormatBool(true)
}

Notes

Atoi and Itoa assume decimal and the Go int type. FormatBool, FormatFloat, FormatInt, and FormatUint go the other way, from values to strings.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go docs, strconv package; Go source, doc.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go docs, strconv package; Go source, doc.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:zbttmycp

iinventedlight. 2026. "Go strconv: convert values to and from strings." iinventedlight Library, iil:note:zbttmycp, version of 2026-11-18. https://iinventedlight.com/library/notes/go-strconv/. License: CC-BY-4.0.

@misc{iil_note_zbttmycp,
  author = {{iinventedlight}},
  title = {{Go strconv: convert values to and from strings}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/go-strconv/},
  note = {Permanent ID iil:note:zbttmycp. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-strconv.md.