InterpretationBox will take care of making safe round trip from boxes to expression but we need to take extra care during condition checking and partition not to evaluate Obj's arguments.
It does not matter that Obj is not holding them, Obj itself can be held. Hold @ Obj[1,2,3,4] etc.
Edit to the old code
As xzczd has noticed, an Input cell with e.g. Obj[1,2,3,4] shows explicit MatrixForm after Ctrl+Shit+N.
Which is strange, the more that I can't reproduce that with combinations of NotebookRead/MakeExpression/MakeBoxes etc.
The problem seems to be caused by TagBox so we can take even more extra care and work around it:
Obj /: MakeBoxes[
o : Obj[args__], StandardForm
] /; IntegerQ @ Sqrt @ Length @ Unevaluated @ args := With[
{ array = (
List @@@ Partition[Hold[args], Sqrt@Length[Unevaluated[args]]]
) /. Hold[lists__] :> Map[
Function[x, MakeBoxes[x, StandardForm], HoldFirst]
, Unevaluated @ {lists}
, {2}
]
}
, InterpretationBox[
RowBox[{ "(", "\[NoBreak]"
, GridBox[array, RowSpacings -> 1, ColumnSpacings -> 1
, RowAlignments -> Baseline, ColumnAlignments -> Center
]
, "\[NoBreak]", ")"
}]
, o
]
]
Old
Obj /: MakeBoxes[
o : Obj[args__], StandardForm
] /; IntegerQ @ Sqrt @ Length[Unevaluated[args]] := With[
{ matrixFormBoxes = (
List @@@ Partition[Hold[args], Sqrt @ Length[Unevaluated[args]]]
) /. Hold[lists__] :> MakeBoxes[MatrixForm[{lists}]]
}
, InterpretationBox[
matrixFormBoxes
, o
]
]
Obj[1, 2, 3, 4]
Obj[1, 2, 4]
Hold @ Obj[Echo[1], 2, 3, 4, 5, 6, 7, 8, 9]

% // ReleaseHold

% // FullForm
Obj[1,2,3,4,5,6,7,8,9]
related:
https://mathematica.stackexchange.com/a/149668/5478
Obj[1, 2, 3, 4]in an input cell, and pressCtrl+Shift+N, then the code will display asMatrixForm[{{x11, x12, x13}, {x21, x22, x23}, {x31, x32, x33}}]. – xzczd Nov 06 '17 at 14:35MakeBoxes[MatrixForm[{lists}]]toMakeBoxes[{lists}, TraditionalForm]. – xzczd Nov 07 '17 at 04:26HoldAllComplete-type holding, to avoid nasty things like:Hold[___, nasty, ___] ^:= Print@"Leak!"; HoldComplete@Obj[1, 2, nasty, 3]. – jkuczm Nov 07 '17 at 13:11HoldCompleteinstead ofHoldandHoldAllCompleteinstead ofHoldFirst. Or did you mean the issue mentioned by xzczd? Then I don't have anything better than what is already in your answer. – jkuczm Nov 07 '17 at 15:00Ctrl+Shift+NcallsBoxForm`ConvertForm[BoxData[RowBox[{"Obj", "[", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "]"}]], StandardForm, StandardForm, "Input"]. It seems thatMakeBoxescalled byBoxForm`ConvertFormsomehow ignores standard formatting of builtin...Formwrappers and convertsMatrixForm[...]toRowBox[{"MatrixForm", "[", ..., "]"}]instead of ordinaryGridBox. I don't know how it happens. – jkuczm Nov 07 '17 at 17:09