After Effects does not export Lottie by itself. You need a plugin that reads your composition and writes the JSON. The original is Bodymovin, maintained by Hernan Torrisi. LottieFiles also has a plugin for After Effects that exports Lottie JSON and dotLottie and can import Lottie files back into After Effects.
Step by step
1. Install the plugin (Bodymovin through aescripts + aeplugins, or LottieFiles from its site). 2. In After Effects open Preferences > Scripting & Expressions and check "Allow Scripts to Write Files and Access Network". 3. Restart After Effects and open the plugin from Window > Extensions. 4. Select your composition, choose an output folder and format, and render. 5. Drop the file into a Lottie web player and play it on a phone.
Build it so it exports cleanly
Lottie is a vector format, so build with shape layers. Illustrator files should be converted with right-click > Create > Create Shapes from Vector Layer. Prefer simple transforms, trim paths, masks and mattes used sparingly, and solid colours or simple gradients.
Things that usually break or bloat the file: most effects (glows, blurs, distortions), particle plugins, 3D camera tricks, heavy expressions and embedded raster images. If you need them, render that part as video instead. The lottie-web README links to the list of supported features; check it before you design something complex.
Check the export
Look at file size, playback on a low-end Android phone, and whether colours and easing match. Very large files often come from embedded images or thousands of keyframes created by baked expressions. Removing those usually helps more than any optimiser.
If the animation needs to respond to taps, hovers or app state rather than just play, a state-machine tool may fit better than a timeline export. Rive and ExodeUI both work that way; we make ExodeUI.