How to make the result of InputForm balance the bracket

If you have Version 11 you can use the function PrettyForm instead of processing InputForm output to get the desired result:

Needs["GeneralUtilities`"]

Interpolation[{1, 2, 3, 4}] // PrettyForm

enter image description here

ListLinePlot[Range[5]^2] // PrettyForm

Mathematica graphics

For earlier versions you can also wrap InputForm with DisplayForm:

ListLinePlot[Range[5]^2] // InputForm // DisplayForm

Mathematica graphics


Per my comment, I like using expr //InputForm //SequenceForm, but another similar possibility is to use a custom head with a custom MakeBoxes rule. For instance, let's call the custom form myInputForm. Then, we can define:

myInputForm /: MakeBoxes[myInputForm[expr_], StandardForm] := MakeBoxes[InputForm[expr]]

We also need to add myInputForm to $OutputForms:

Unprotect[$OutputForms];

AppendTo[$OutputForms, myInputForm];

Protect[$OutputForms];

Now, myInputForm gets stripped before being stored in Out. For instance:

Interpolation[{1,2,3,4}]
% //myInputForm
% //Head

InterpolatingFunction[{{1, 4}}, <>]

InterpolatingFunction[{{1, 4}}, { 5, 3, 0, {4}, {4}, 0, 0, 0, 0, Automatic, {}, {}, False}, {{1, 2, 3, 4}}, {{ 1}, {2}, {3}, {4}}, {Automatic}]

InterpolatingFunction


Carl's tip seems to be the best quick solution.

Very often I find syntax/style highlighting very useful too so I use:

CellPrint[ExpressionCell[InputForm@#, "Input"]] &

to get everything what Input cells offer:

Plot[x, {x, 0, 1}, PlotPoints -> 10, MaxRecursion -> 1
] // CellPrint[ExpressionCell[InputForm@#, "Input"]] &

enter image description here

related:

How to see a code preview (in Experimental`Explore[] or related GUI)

How to use an ExpressionCell to display e.g. an Input cell inside a generated output?