This study presents a versatile ontology for describing all kinds of smart or stimuli-responsive 4D printed material systems and structures. The different components of the ontology, namely: initial geometry and shape, shape-morphing principle(s), triggering stimuli, intermediate/final geometry and shape, 4D material and printing or additive manufacturing technology, are enumerated and classified. Accordingly, a codification system for schematically illustrating the actuation cycle of 4D printed material systems and structures, and shape-morphing devices in general, is proposed. The systematic application of the ontology to a relevant set of examples helps to demonstrate its utility and adaptability to many different types of 4D printed objects. It demonstrates that the ontology and codification schemes developed in this research can serve a comprehensive classification tool for the emergent field of 4D printing. It is the first ontology capable of representing the multiple actuation steps of complex 4D printed devices and actuators, in which several metamorphoses may be achievable, due to combinations of different shape-morphing principles and triggering stimuli. To this end, a single line of code is required. A glossary is provided to support its implementation and application. Besides, the usability of the ontology and related codification by a generative artificial intelligence (AI) for supporting engineering design tasks is explored and validated through a set of examples and an industrial use case. This work is expected to provide a universal language to facilitate the communication in the 4D materials and printing field, as well as a synergic generative AI-based methodology for creativity promotion linked to innovative smart 4D printed material systems and structures.