JSON_PP(1perl)

πŸ“¦
version 5.44.0 Β· 2 versions
, in arch rolling

πŸ’– json_pp β€” the manual, but make it make sense πŸ’–

okay bestie, sit down, hydrate, because we're talking about json_pp, the little command-line icon from the JSON::PP family. This page lives in the Perl Programmers Reference Guide section of the manual, section 1perl. Yes, that means it's a user command. Yes, that means you can literally just run it. Slay. πŸŽ€


✨ NAME ✨

json_pp β€” the JSON::PP command utility. that's it, that's the whole name. short, sweet, does exactly what it says on the tin. πŸ¦‹


✨ SYNOPSIS ✨

the vibe check, in one line:

json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json1[,options_to_json2[,...]]]

that's the shape of it. flags, a from-format, a to-format, some JSON::PP options. we love a predictable girlie. πŸ’…


✨ DESCRIPTION ✨

so here's the tea β˜• β€” json_pp converts between some input and output formats, and yeah, one of those formats is JSON (obviously, it's in the name, the main character energy is off the charts).

fun fact for the lore girlies: this program was copied from json_xs and then modified. glow-up era. ✨

Default behaviour, because defaults matter:

  • the default input format is json
  • the default output format is json with the pretty option

so if you just piped something in and didn't say anything else, it'd come out pretty-printed. thoughtful queen. πŸ‘‘


✨ OPTIONS ✨

πŸŽ€ -f

-f from_format

Reads a data in the given format from STDIN. (Yes, it's reading from STDIN. Pipe it in, bestie.)

Format types you can hand it:

  • json β€” as JSON
  • eval β€” as Perl code

two options, both iconic, pick your fighter. πŸ’–

πŸŽ€ -t

Writes a data in the given format to STDOUT.

Format types:

  • null β€” no action.
  • json β€” as JSON
  • dumper β€” as Data::Dumper

(null being a valid output format that does literally nothing is so real of it ngl 😭)

πŸŽ€ -json_opt

options to JSON::PP. let's go, this is the big one.

Acceptable options are:

ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
allow_singlequote allow_barekey allow_bignum loose escape_slash indent_length
🚨 the one rule, bestie, don't mess this up: Multiple options must be separated by commas.

Right: -json_opt pretty,canonical

Wrong: -json_opt pretty -json_opt canonical

like. the comma matters. the comma is the whole girl. fr fr. commas are doing the heavy lifting and the second version is NOT it. 🫢

πŸŽ€ -v

Verbose option, but currently no action in fact. πŸ’€

(not me expecting verbose output and getting absolutely nothing β€” she's cosplaying as a real flag out here.)

πŸŽ€ -V

Prints version and exits. this one actually works, king behaviour. ⭐


✨ EXAMPLES ✨

here's where it gets good. watch what happens with a big ol' number and some Japanese text in the mix. 🌸

First up, with pretty,utf8,allow_bignum:

$ perl -e'print q|{"foo":"あい","bar":1234567890000000000000000}|' |\
   json_pp -f json -t dumper -json_opt pretty,utf8,allow_bignum

$VAR1 = {
          'bar' => bless( {
                            'value' => [
                                         '0000000',
                                         '0000000',
                                         '5678900',
                                         '1234'
                                       ],
                            'sign' => '+'
                          }, 'Math::BigInt' ),
          'foo' => "\x{3042}\x{3044}"
        };

see how the big number got blessed into a Math::BigInt? that's the allow_bignum working. and foo came out as proper characters. ate. πŸ”₯

Then the exact same input, but with just pretty:

$ perl -e'print q|{"foo":"あい","bar":1234567890000000000000000}|' |\
   json_pp -f json -t dumper -json_opt pretty

$VAR1 = {
          'bar' => '1234567890000000000000000',
          'foo' => "\x{e3}\x{81}\x{82}\x{e3}\x{81}\x{84}"
        };

and now the number is just a plain string, and the text is a pile of escaped bytes. same input, different flags, completely different glow. the way that -json_opt changes everything… it's giving control freak in the best way. 🌈


✨ SEE ALSO ✨

go read these next, bestie, do it for me:

  • JSON::PP
  • json_xs

✨ AUTHOR ✨

Makamaka Hannyaharamitu, <makamaka[at]cpan.org> β€” thank you for your service, legend 🫢


Copyright 2010 by Makamaka Hannyaharamitu

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. (yes, the classic Perl-itself clause. free as in freedom, we love to see it. πŸ’œ)


okay that's the whole page!! πŸ¦‹ and for the cute sign-off: this beauty is from perl v5.44.0, dated 2026-10-17, filed under JSON_PP(1perl). go forth and pretty-print something. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms