Motion is a major confound in diffusion-weighted imaging (DWI) in the body, and it is a common cause of image artefacts. The effects are particularly severe in cardiac applications, due to the nonrigid cyclical deformation of the myocardium. Spin echo-based DWI commonly employs gradient moment-nulling techniques to desensitise the acquisition to velocity and acceleration, ie, nulling gradient moments up to the 2nd order (M2-nulled). However, current M2-nulled DWI scans are limited to encode diffusion along a single direction at a time. We propose a method for designing b-tensors of arbitrary shapes, including planar, spherical, prolate and oblate tensors, while nulling gradient moments up to the 2nd order and beyond. The design strategy comprises initialising the diffusion encoding gradients in two encoding blocks about the refocusing pulse, followed by appropriate scaling and rotation, which further enables nulling undesired effects of concomitant gradients. Proof-of-concept assessment of in vivo mean diffusivity (MD) was performed using linear and spherical tensor encoding (LTE and STE, respectively) in the hearts of five healthy volunteers. The results of the M2-nulled STE showed that (a) the sequence was robust to cardiac motion, and (b) MD was higher than that acquired using standard M2-nulled LTE, where diffusion-weighting was applied in three orthogonal directions, which may be attributed to the presence of restricted diffusion and microscopic diffusion anisotropy. Provided adequate signal-to-noise ratio, STE could significantly shorten estimation of MD compared with the conventional LTE approach. Importantly, our theoretical analysis and the proposed gradient waveform design may be useful in microstructure imaging beyond diffusion tensor imaging where the effects of motion must be suppressed.