Look at the style and structure. Fiction usually has a plot, characters' development, and a fictional setting. Nonfiction often presents facts, research, and real-life examples. Another clue is the source of the material. If it comes from research or real experiences, it's nonfiction. If it's purely from the author's imagination, it's fiction.
You can determine it by the author's intent. If the aim is to inform or present real information, it's nonfiction. If the goal is to entertain through imagination and creativity, it's fiction. Also, check the genre labels and the way the story is presented. Nonfiction often has a more straightforward and factual tone.
One way to tell is by looking at the content. If it's based on real events, people, or facts, it's likely nonfiction. If it's made-up stories, characters, and worlds, it's probably fiction.