• Version 28.1.3
  • Published
  • 64.1 kB
  • 4 dependencies
  • MIT license


npm i pretty-format
yarn add pretty-format
pnpm add pretty-format


Stringify any JavaScript value.




const DEFAULT_OPTIONS: Options;

    variable plugins

    const plugins: {
    AsymmetricMatcher: NewPlugin;
    ConvertAnsi: NewPlugin;
    DOMCollection: NewPlugin;
    DOMElement: NewPlugin;
    Immutable: NewPlugin;
    ReactElement: NewPlugin;
    ReactTestComponent: NewPlugin;


      function format

      format: (val: unknown, options?: OptionsReceived) => string;
      • Returns a presentation string of your val object

        Parameter val

        any potential JavaScript object

        Parameter options

        Custom settings


      interface Options

      interface Options extends Omit<RequiredOptions, 'compareKeys' | 'theme'> {}

        property compareKeys

        compareKeys: CompareKeys;

          property theme

          theme: Required<RequiredOptions['theme']>;

            interface PrettyFormatOptions

            interface PrettyFormatOptions extends SnapshotFormat {}

              property compareKeys

              compareKeys?: CompareKeys;

                property plugins

                plugins?: Plugins;

                  Type Aliases

                  type Colors

                  type Colors = {
                  comment: {
                  close: string;
                  open: string;
                  content: {
                  close: string;
                  open: string;
                  prop: {
                  close: string;
                  open: string;
                  tag: {
                  close: string;
                  open: string;
                  value: {
                  close: string;
                  open: string;

                    type CompareKeys

                    type CompareKeys = ((a: string, b: string) => number) | undefined;

                      type Config

                      type Config = {
                      callToJSON: boolean;
                      compareKeys: CompareKeys;
                      colors: Colors;
                      escapeRegex: boolean;
                      escapeString: boolean;
                      indent: string;
                      maxDepth: number;
                      maxWidth: number;
                      min: boolean;
                      plugins: Plugins;
                      printBasicPrototype: boolean;
                      printFunctionName: boolean;
                      spacingInner: string;
                      spacingOuter: string;

                        type NewPlugin

                        type NewPlugin = {
                        serialize: (
                        val: any,
                        config: Config,
                        indentation: string,
                        depth: number,
                        refs: Refs,
                        printer: Printer
                        ) => string;
                        test: Test;

                          type OldPlugin

                          type OldPlugin = {
                          print: (
                          val: unknown,
                          print: Print,
                          indent: Indent,
                          options: PluginOptions,
                          colors: Colors
                          ) => string;
                          test: Test;

                            type OptionsReceived

                            type OptionsReceived = PrettyFormatOptions;

                              type Plugin

                              type Plugin_2 = NewPlugin | OldPlugin;

                                type Plugins

                                type Plugins = Array<Plugin_2>;

                                  type Printer

                                  type Printer = (
                                  val: unknown,
                                  config: Config,
                                  indentation: string,
                                  depth: number,
                                  refs: Refs,
                                  hasCalledToJSON?: boolean
                                  ) => string;

                                    type Refs

                                    type Refs = Array<unknown>;

                                      type Theme

                                      type Theme = Options['theme'];

                                        Package Files (1)

                                        Dependencies (4)

                                        Dev Dependencies (9)

                                        Peer Dependencies (0)

                                        No peer dependencies.


                                        To add a badge like this badgeto your package's README, use the codes available below.

                                        You may also use to create a custom badge linking to

                                        • Markdown
                                        • HTML
                                          <a href=""><img src="" alt=""></a>