Skip to content
masterclass Buddy

Go · Function

json.Marshal

json.Marshal converts a Go value into JSON bytes. It returns the encoded bytes and an error.

Last updated

Syntax

func Marshal(v any) ([]byte, error)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • MarshalIndent
  • Marshaler
  • Unmarshaler
  • Encoder
  • UnsupportedTypeError
  • UnsupportedValueError

Source: json package - encoding/json - Go Packages. Checked 2026-11-03.