How do I know sprained or broke my toe?

Toe injury. X rays of the toe would reveal a fracture or not. A sprain is an injury to the ligaments connecting bone to bone, including a stretching or tearing of these ligaments. X rays in this case may be normal aside from possible soft tissue swelling noted.
Hard to know? Deformity with dislocation or fracture. Swelling with those and sprain as well as bruising. Exam my tell in good hands but usually x-ray is needed. Depends on the toe as well. May be easier to tell in great toe versus little toe. Get checked out by your pcp!
X-ray. Is needed and you will know.
Doctor can evaluate. If a toe is swollen from trauma, one can try to move the joints of the toe. If the joints are movable in the normal directions, without crunching noises, without severe pain, then it is probably not broken. If the toe is crooked, has great pain when moved, or looks shorter than normal, it probably is broken. Many times it is hard to tell without an x-ray, so a doctor's evaluation may be needed.