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
strconvconverts to and from string representations of basic data types.Atoiconverts a string to int; Itoa converts an int to a string.ParseBoolParseFloat, ParseInt, and ParseUint convert strings to values.
See also
Claims
- id: C1 claim: strconv converts to and from string representations of basic data types. source: S1 evidence: "Package strconv implements conversions"
- id: C2 claim: Atoi converts a string to int; Itoa converts an int to a string. source: S2 evidence: "The most common numeric conversions are [Atoi] (string to int) and [Itoa] (int to string)"
- id: C3 claim: ParseBool, ParseFloat, ParseInt, and ParseUint convert strings to values. source: S2 evidence: "[ParseBool], [ParseFloat], [ParseInt], and [ParseUint] convert strings to values"
Sources
- [S1] strconv package. Go docs. https://pkg.go.dev/strconv . License: BSD-3-Clause. Accessed 2026-11-18.
- [S2] doc.go. Go source. https://raw.githubusercontent.com/golang/go/master/src/strconv/doc.go . License: BSD-3-Clause. Accessed 2026-11-18.
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
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.},
}
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.
- go-strconv.table.json (table; CC-BY-4.0)
- go-strconv.schema.json (schema; CC-BY-4.0)
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.