This paper describes CosmoLattice, a modern package for lattice simulations of the dynamics of interacting scalar and gauge fields in an expanding universe. CosmoLattice incorporates a series of features that makes it very versatile and powerful: i) it is written in C++ fully exploiting the object oriented programming paradigm, with a modular structure and a clear separation between the physics and the technical details, ii) it is MPI-based and uses a discrete Fourier transform parallelized in multiple spatial dimensions, which makes it specially appropriate for probing scenarios with well-separated scales, running very high resolution simulations, or simply very long ones, iii) it introduces its own symbolic language, defining field variables and operations over them, so that one can introduce differential equations and operators in a manner as close as possible to the continuum, iv) it includes a library of numerical algorithms, ranging from O(δt2) to O(δt10) methods, suitable for simulating global and gauge theories in an expanding grid, including the case of ‘self-consistent’ expansion sourced by the fields themselves. Relevant observables are provided for each algorithm (e.g. energy densities, field spectra, lattice snapshots) and we note that, remarkably, all our algorithms for gauge theories (Abelian or non-Abelian) always respect the Gauss constraint to machine precision. Program summaryProgram Title::CosmoLatticeCPC Library link to program files:https://doi.org/10.17632/44vr5xssc6.1Developer's repository link:http://github.com/cosmolattice/cosmolatticeLicensing provisions: MITProgramming language: C++, MPINature of problem: The phenomenology of high energy physics in the early universe is typically characterized by non-linear dynamics, which cannot be captured accurately with analytical techniques. In order to fully understand the non-linearities developed in a given scenario, one needs to carry out lattice simulations. A number of public packages for lattice simulations have appeared over the years, but most of them are only capable of simulating scalar fields. However, realistic models of particle physics do contain other kind of field species, such as (Abelian or non-Abelian) gauge fields, whose non-linear dynamics can also play a relevant role in the early universe. Tensor modes representing gravitational waves are also naturally expected in many scenarios.Solution method:CosmoLattice represents a modern code for lattice simulations of scalar-gauge field theories in an expanding universe. It allows for the simulation of the evolution of interacting (singlet) scalar fields, charged scalar fields under U(1) and/or SU(2) gauge groups, and the corresponding associated Abelian and/or non-Abelian gauge fields. From version 1.1 onward, CosmoLattice also allows to simulate the production of gravitational waves. Simulations can be done either in a flat space-time background, or in a homogeneous and isotropic (spatially flat) expanding FLRW background. CosmoLattice provides symplectic integrators, with accuracy ranging from O(δt2) up to O(δt10), to simulate the non-linear dynamics of the appropriate fields in comoving three-dimensional lattices. The code is parallelized with MPI, and uses a discrete Fourier Transform parallelized in multiple spatial dimensions, which makes it a very powerful code for probing physical problems with well-separated scales. Moreover, the code has been designed as a ‘platform’ to implement any system of dynamical equations suitable for discretization on a lattice.