This is one of the most viewed Lottie questions on Stack Overflow, and the honest answer has two parts.
The quick way: a converter
LottieFiles has a free GIF to Lottie tool that also accepts MP4, MOV, WebM and PNG. Upload the GIF (up to 10 MB), pick an output and download a Lottie or dotLottie file. This is useful when a platform only accepts Lottie, or you want one player for all your animations.
Why the result may disappoint
A GIF is a stack of pixel images. A real Lottie is a list of vector shapes and keyframes. Unless a converter traces the frames into vector shapes well, the output carries pixel data inside the JSON. Then it will not scale cleanly, and the file can end up as large as the GIF or larger. Open the result, zoom in, and compare file sizes.
The better way: rebuild as vectors
For anything you will ship in an app, such as a spinner, a checkmark or an icon, redraw it with vector shapes. If you have the source file in After Effects, export with Bodymovin or the LottieFiles plugin. If you only have the GIF, trace the key poses in Figma or Illustrator and animate them again. It takes longer once and pays back in size and sharpness.
If the animation also needs to react to the user, build it in a tool with states instead of rebuilding a timeline. Rive and ExodeUI both do this; we make ExodeUI.